From bf6655a534a6775d30cafa67bd801276bda1d98d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 13 Aug 2024 23:45:21 +0200 Subject: =?UTF-8?q?VERSION=200.2=20doctrine=20ORM=20et=20entit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Command/AbstractEntityManagerCommand.php | 25 ++ .../Command/ClearCache/CollectionRegionCommand.php | 119 +++++++++ .../Command/ClearCache/EntityRegionCommand.php | 110 ++++++++ .../Console/Command/ClearCache/MetadataCommand.php | 52 ++++ .../Console/Command/ClearCache/QueryCommand.php | 54 ++++ .../Command/ClearCache/QueryRegionCommand.php | 101 ++++++++ .../Console/Command/ClearCache/ResultCommand.php | 65 +++++ .../Console/Command/GenerateProxiesCommand.php | 96 +++++++ .../orm/src/Tools/Console/Command/InfoCommand.php | 80 ++++++ .../Console/Command/MappingDescribeCommand.php | 279 +++++++++++++++++++++ .../src/Tools/Console/Command/RunDqlCommand.php | 118 +++++++++ .../Console/Command/SchemaTool/AbstractCommand.php | 39 +++ .../Console/Command/SchemaTool/CreateCommand.php | 75 ++++++ .../Console/Command/SchemaTool/DropCommand.php | 116 +++++++++ .../Console/Command/SchemaTool/UpdateCommand.php | 147 +++++++++++ .../Console/Command/ValidateSchemaCommand.php | 89 +++++++ .../orm/src/Tools/Console/ConsoleRunner.php | 88 +++++++ .../src/Tools/Console/EntityManagerProvider.php | 14 ++ .../ConnectionFromManagerProvider.php | 26 ++ .../SingleManagerProvider.php | 31 +++ .../UnknownManagerException.php | 23 ++ .../orm/src/Tools/Console/MetadataFilter.php | 92 +++++++ 22 files changed, 1839 insertions(+) create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/AbstractEntityManagerCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/CollectionRegionCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/EntityRegionCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/MetadataCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryRegionCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/ResultCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/GenerateProxiesCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/InfoCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/MappingDescribeCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/RunDqlCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/AbstractCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/CreateCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/DropCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/UpdateCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/Command/ValidateSchemaCommand.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/ConnectionFromManagerProvider.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/UnknownManagerException.php create mode 100644 vendor/doctrine/orm/src/Tools/Console/MetadataFilter.php (limited to 'vendor/doctrine/orm/src/Tools/Console') diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/AbstractEntityManagerCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/AbstractEntityManagerCommand.php new file mode 100644 index 0000000..370f4fb --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/AbstractEntityManagerCommand.php @@ -0,0 +1,25 @@ +getOption('em') === null + ? $this->entityManagerProvider->getDefaultManager() + : $this->entityManagerProvider->getManager($input->getOption('em')); + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/CollectionRegionCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/CollectionRegionCommand.php new file mode 100644 index 0000000..b4c6efa --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/CollectionRegionCommand.php @@ -0,0 +1,119 @@ +setName('orm:clear-cache:region:collection') + ->setDescription('Clear a second-level cache collection region') + ->addArgument('owner-class', InputArgument::OPTIONAL, 'The owner entity name.') + ->addArgument('association', InputArgument::OPTIONAL, 'The association collection name.') + ->addArgument('owner-id', InputArgument::OPTIONAL, 'The owner identifier.') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.') + ->setHelp(<<<'EOT' +The %command.name% command is meant to clear a second-level cache collection regions for an associated Entity Manager. +It is possible to delete/invalidate all collection region, a specific collection region or flushes the cache provider. + +The execution type differ on how you execute the command. +If you want to invalidate all entries for an collection region this command would do the work: + +%command.name% 'Entities\MyEntity' 'collectionName' + +To invalidate a specific entry you should use : + +%command.name% 'Entities\MyEntity' 'collectionName' 1 + +If you want to invalidate all entries for the all collection regions: + +%command.name% --all + +Alternatively, if you want to flush the configured cache provider for an collection region use this command: + +%command.name% 'Entities\MyEntity' 'collectionName' --flush + +Finally, be aware that if --flush option is passed, +not all cache providers are able to flush entries, because of a limitation of its execution nature. +EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + $ownerClass = $input->getArgument('owner-class'); + $assoc = $input->getArgument('association'); + $ownerId = $input->getArgument('owner-id'); + $cache = $em->getCache(); + + if (! $cache instanceof Cache) { + throw new InvalidArgumentException('No second-level cache is configured on the given EntityManager.'); + } + + if (( ! $ownerClass || ! $assoc) && ! $input->getOption('all')) { + throw new InvalidArgumentException('Missing arguments "--owner-class" "--association"'); + } + + if ($input->getOption('flush')) { + $cache->getCollectionCacheRegion($ownerClass, $assoc) + ->evictAll(); + + $ui->comment( + sprintf( + 'Flushing cache provider configured for "%s#%s"', + $ownerClass, + $assoc, + ), + ); + + return 0; + } + + if ($input->getOption('all')) { + $ui->comment('Clearing all second-level cache collection regions'); + + $cache->evictEntityRegions(); + + return 0; + } + + if ($ownerId) { + $ui->comment( + sprintf( + 'Clearing second-level cache entry for collection "%s#%s" owner entity identified by "%s"', + $ownerClass, + $assoc, + $ownerId, + ), + ); + $cache->evictCollection($ownerClass, $assoc, $ownerId); + + return 0; + } + + $ui->comment(sprintf('Clearing second-level cache for collection "%s#%s"', $ownerClass, $assoc)); + $cache->evictCollectionRegion($ownerClass, $assoc); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/EntityRegionCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/EntityRegionCommand.php new file mode 100644 index 0000000..c5f2d65 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/EntityRegionCommand.php @@ -0,0 +1,110 @@ +setName('orm:clear-cache:region:entity') + ->setDescription('Clear a second-level cache entity region') + ->addArgument('entity-class', InputArgument::OPTIONAL, 'The entity name.') + ->addArgument('entity-id', InputArgument::OPTIONAL, 'The entity identifier.') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all entity regions will be deleted/invalidated.') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.') + ->setHelp(<<<'EOT' +The %command.name% command is meant to clear a second-level cache entity region for an associated Entity Manager. +It is possible to delete/invalidate all entity region, a specific entity region or flushes the cache provider. + +The execution type differ on how you execute the command. +If you want to invalidate all entries for an entity region this command would do the work: + +%command.name% 'Entities\MyEntity' + +To invalidate a specific entry you should use : + +%command.name% 'Entities\MyEntity' 1 + +If you want to invalidate all entries for the all entity regions: + +%command.name% --all + +Alternatively, if you want to flush the configured cache provider for an entity region use this command: + +%command.name% 'Entities\MyEntity' --flush + +Finally, be aware that if --flush option is passed, +not all cache providers are able to flush entries, because of a limitation of its execution nature. +EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + $entityClass = $input->getArgument('entity-class'); + $entityId = $input->getArgument('entity-id'); + $cache = $em->getCache(); + + if (! $cache instanceof Cache) { + throw new InvalidArgumentException('No second-level cache is configured on the given EntityManager.'); + } + + if (! $entityClass && ! $input->getOption('all')) { + throw new InvalidArgumentException('Invalid argument "--entity-class"'); + } + + if ($input->getOption('flush')) { + $cache->getEntityCacheRegion($entityClass) + ->evictAll(); + + $ui->comment(sprintf('Flushing cache provider configured for entity named "%s"', $entityClass)); + + return 0; + } + + if ($input->getOption('all')) { + $ui->comment('Clearing all second-level cache entity regions'); + + $cache->evictEntityRegions(); + + return 0; + } + + if ($entityId) { + $ui->comment( + sprintf( + 'Clearing second-level cache entry for entity "%s" identified by "%s"', + $entityClass, + $entityId, + ), + ); + $cache->evictEntity($entityClass, $entityId); + + return 0; + } + + $ui->comment(sprintf('Clearing second-level cache for entity "%s"', $entityClass)); + $cache->evictEntityRegion($entityClass); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/MetadataCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/MetadataCommand.php new file mode 100644 index 0000000..147795b --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/MetadataCommand.php @@ -0,0 +1,52 @@ +setName('orm:clear-cache:metadata') + ->setDescription('Clear all metadata cache of the various cache drivers') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, cache entries will be flushed instead of deleted/invalidated.') + ->setHelp(<<<'EOT' +The %command.name% command is meant to clear the metadata cache of associated Entity Manager. +EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + $cacheDriver = $em->getConfiguration()->getMetadataCache(); + + if (! $cacheDriver) { + throw new InvalidArgumentException('No Metadata cache driver is configured on given EntityManager.'); + } + + $ui->comment('Clearing all Metadata cache entries'); + + $result = $cacheDriver->clear(); + $message = $result ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; + + $ui->success($message); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryCommand.php new file mode 100644 index 0000000..83edd7a --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryCommand.php @@ -0,0 +1,54 @@ +setName('orm:clear-cache:query') + ->setDescription('Clear all query cache of the various cache drivers') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->setHelp('The %command.name% command is meant to clear the query cache of associated Entity Manager.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + $cache = $em->getConfiguration()->getQueryCache(); + + if (! $cache) { + throw new InvalidArgumentException('No Query cache driver is configured on given EntityManager.'); + } + + if ($cache instanceof ApcuAdapter) { + throw new LogicException('Cannot clear APCu Cache from Console, it\'s shared in the Webserver memory and not accessible from the CLI.'); + } + + $ui->comment('Clearing all Query cache entries'); + + $message = $cache->clear() ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; + + $ui->success($message); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryRegionCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryRegionCommand.php new file mode 100644 index 0000000..e80fb90 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/QueryRegionCommand.php @@ -0,0 +1,101 @@ +setName('orm:clear-cache:region:query') + ->setDescription('Clear a second-level cache query region') + ->addArgument('region-name', InputArgument::OPTIONAL, 'The query region to clear.') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('all', null, InputOption::VALUE_NONE, 'If defined, all query regions will be deleted/invalidated.') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, all cache entries will be flushed.') + ->setHelp(<<<'EOT' +The %command.name% command is meant to clear a second-level cache query region for an associated Entity Manager. +It is possible to delete/invalidate all query region, a specific query region or flushes the cache provider. + +The execution type differ on how you execute the command. +If you want to invalidate all entries for the default query region this command would do the work: + +%command.name% + +To invalidate entries for a specific query region you should use : + +%command.name% my_region_name + +If you want to invalidate all entries for the all query region: + +%command.name% --all + +Alternatively, if you want to flush the configured cache provider use this command: + +%command.name% my_region_name --flush + +Finally, be aware that if --flush option is passed, +not all cache providers are able to flush entries, because of a limitation of its execution nature. +EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + $name = $input->getArgument('region-name'); + $cache = $em->getCache(); + + if ($name === null) { + $name = Cache::DEFAULT_QUERY_REGION_NAME; + } + + if (! $cache instanceof Cache) { + throw new InvalidArgumentException('No second-level cache is configured on the given EntityManager.'); + } + + if ($input->getOption('flush')) { + $cache->getQueryCache($name) + ->getRegion() + ->evictAll(); + + $ui->comment( + sprintf( + 'Flushing cache provider configured for second-level cache query region named "%s"', + $name, + ), + ); + + return 0; + } + + if ($input->getOption('all')) { + $ui->comment('Clearing all second-level cache query regions'); + + $cache->evictQueryRegions(); + + return 0; + } + + $ui->comment(sprintf('Clearing second-level cache query region named "%s"', $name)); + $cache->evictQueryRegion($name); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/ResultCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/ResultCommand.php new file mode 100644 index 0000000..4f84e0b --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/ResultCommand.php @@ -0,0 +1,65 @@ +setName('orm:clear-cache:result') + ->setDescription('Clear all result cache of the various cache drivers') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('flush', null, InputOption::VALUE_NONE, 'If defined, cache entries will be flushed instead of deleted/invalidated.') + ->setHelp(<<<'EOT' +The %command.name% command is meant to clear the result cache of associated Entity Manager. +It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider +instance completely. + +The execution type differ on how you execute the command. +If you want to invalidate the entries (and not delete from cache instance), this command would do the work: + +%command.name% + +Alternatively, if you want to flush the cache provider using this command: + +%command.name% --flush + +Finally, be aware that if --flush option is passed, not all cache providers are able to flush entries, +because of a limitation of its execution nature. +EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + $cache = $em->getConfiguration()->getResultCache(); + + if (! $cache) { + throw new InvalidArgumentException('No Result cache driver is configured on given EntityManager.'); + } + + $ui->comment('Clearing all Result cache entries'); + + $message = $cache->clear() ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.'; + + $ui->success($message); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/GenerateProxiesCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/GenerateProxiesCommand.php new file mode 100644 index 0000000..5a407de --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/GenerateProxiesCommand.php @@ -0,0 +1,96 @@ +setName('orm:generate-proxies') + ->setAliases(['orm:generate:proxies']) + ->setDescription('Generates proxy classes for entity classes') + ->addArgument('dest-path', InputArgument::OPTIONAL, 'The path to generate your proxy classes. If none is provided, it will attempt to grab from configuration.') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('filter', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A string pattern used to match entities that should be processed.') + ->setHelp('Generates proxy classes for entity classes.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + + $metadatas = $em->getMetadataFactory()->getAllMetadata(); + $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); + + // Process destination directory + $destPath = $input->getArgument('dest-path'); + if ($destPath === null) { + $destPath = $em->getConfiguration()->getProxyDir(); + + if ($destPath === null) { + throw new InvalidArgumentException('Proxy directory cannot be null'); + } + } + + if (! is_dir($destPath)) { + mkdir($destPath, 0775, true); + } + + $destPath = realpath($destPath); + + if (! file_exists($destPath)) { + throw new InvalidArgumentException( + sprintf("Proxies destination directory '%s' does not exist.", $em->getConfiguration()->getProxyDir()), + ); + } + + if (! is_writable($destPath)) { + throw new InvalidArgumentException( + sprintf("Proxies destination directory '%s' does not have write permissions.", $destPath), + ); + } + + if (empty($metadatas)) { + $ui->success('No Metadata Classes to process.'); + + return 0; + } + + foreach ($metadatas as $metadata) { + $ui->text(sprintf('Processing entity "%s"', $metadata->name)); + } + + // Generating Proxies + $em->getProxyFactory()->generateProxyClasses($metadatas, $destPath); + + // Outputting information message + $ui->newLine(); + $ui->text(sprintf('Proxy classes generated to "%s"', $destPath)); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/InfoCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/InfoCommand.php new file mode 100644 index 0000000..deebb58 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/InfoCommand.php @@ -0,0 +1,80 @@ +setName('orm:info') + ->setDescription('Show basic information about all mapped entities') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->setHelp(<<<'EOT' +The %command.name% shows basic information about which +entities exist and possibly if their mapping information contains errors or +not. +EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $entityManager = $this->getEntityManager($input); + + $entityClassNames = $entityManager->getConfiguration() + ->getMetadataDriverImpl() + ->getAllClassNames(); + + if (! $entityClassNames) { + $ui->caution( + [ + 'You do not have any mapped Doctrine ORM entities according to the current configuration.', + 'If you have entities or mapping files you should check your mapping configuration for errors.', + ], + ); + + return 1; + } + + $ui->text(sprintf('Found %d mapped entities:', count($entityClassNames))); + $ui->newLine(); + + $failure = false; + + foreach ($entityClassNames as $entityClassName) { + try { + $entityManager->getClassMetadata($entityClassName); + $ui->text(sprintf('[OK] %s', $entityClassName)); + } catch (MappingException $e) { + $ui->text( + [ + sprintf('[FAIL] %s', $entityClassName), + sprintf('%s', $e->getMessage()), + '', + ], + ); + + $failure = true; + } + } + + return $failure ? 1 : 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/MappingDescribeCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/MappingDescribeCommand.php new file mode 100644 index 0000000..41a177d --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/MappingDescribeCommand.php @@ -0,0 +1,279 @@ +setName('orm:mapping:describe') + ->addArgument('entityName', InputArgument::REQUIRED, 'Full or partial name of entity') + ->setDescription('Display information about mapped objects') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->setHelp(<<<'EOT' +The %command.full_name% command describes the metadata for the given full or partial entity class name. + + %command.full_name% My\Namespace\Entity\MyEntity + +Or: + + %command.full_name% MyEntity +EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $entityManager = $this->getEntityManager($input); + + $this->displayEntity($input->getArgument('entityName'), $entityManager, $ui); + + return 0; + } + + /** + * Display all the mapping information for a single Entity. + * + * @param string $entityName Full or partial entity class name + */ + private function displayEntity( + string $entityName, + EntityManagerInterface $entityManager, + SymfonyStyle $ui, + ): void { + $metadata = $this->getClassMetadata($entityName, $entityManager); + + $ui->table( + ['Field', 'Value'], + array_merge( + [ + $this->formatField('Name', $metadata->name), + $this->formatField('Root entity name', $metadata->rootEntityName), + $this->formatField('Custom generator definition', $metadata->customGeneratorDefinition), + $this->formatField('Custom repository class', $metadata->customRepositoryClassName), + $this->formatField('Mapped super class?', $metadata->isMappedSuperclass), + $this->formatField('Embedded class?', $metadata->isEmbeddedClass), + $this->formatField('Parent classes', $metadata->parentClasses), + $this->formatField('Sub classes', $metadata->subClasses), + $this->formatField('Embedded classes', $metadata->subClasses), + $this->formatField('Identifier', $metadata->identifier), + $this->formatField('Inheritance type', $metadata->inheritanceType), + $this->formatField('Discriminator column', $metadata->discriminatorColumn), + $this->formatField('Discriminator value', $metadata->discriminatorValue), + $this->formatField('Discriminator map', $metadata->discriminatorMap), + $this->formatField('Generator type', $metadata->generatorType), + $this->formatField('Table', $metadata->table), + $this->formatField('Composite identifier?', $metadata->isIdentifierComposite), + $this->formatField('Foreign identifier?', $metadata->containsForeignIdentifier), + $this->formatField('Enum identifier?', $metadata->containsEnumIdentifier), + $this->formatField('Sequence generator definition', $metadata->sequenceGeneratorDefinition), + $this->formatField('Change tracking policy', $metadata->changeTrackingPolicy), + $this->formatField('Versioned?', $metadata->isVersioned), + $this->formatField('Version field', $metadata->versionField), + $this->formatField('Read only?', $metadata->isReadOnly), + + $this->formatEntityListeners($metadata->entityListeners), + ], + [$this->formatField('Association mappings:', '')], + $this->formatMappings($metadata->associationMappings), + [$this->formatField('Field mappings:', '')], + $this->formatMappings($metadata->fieldMappings), + ), + ); + } + + /** + * Return all mapped entity class names + * + * @return string[] + * @psalm-return class-string[] + */ + private function getMappedEntities(EntityManagerInterface $entityManager): array + { + $entityClassNames = $entityManager->getConfiguration() + ->getMetadataDriverImpl() + ->getAllClassNames(); + + if (! $entityClassNames) { + throw new InvalidArgumentException( + 'You do not have any mapped Doctrine ORM entities according to the current configuration. ' . + 'If you have entities or mapping files you should check your mapping configuration for errors.', + ); + } + + return $entityClassNames; + } + + /** + * Return the class metadata for the given entity + * name + * + * @param string $entityName Full or partial entity name + */ + private function getClassMetadata( + string $entityName, + EntityManagerInterface $entityManager, + ): ClassMetadata { + try { + return $entityManager->getClassMetadata($entityName); + } catch (MappingException) { + } + + $matches = array_filter( + $this->getMappedEntities($entityManager), + static fn ($mappedEntity) => preg_match('{' . preg_quote($entityName) . '}', $mappedEntity) + ); + + if (! $matches) { + throw new InvalidArgumentException(sprintf( + 'Could not find any mapped Entity classes matching "%s"', + $entityName, + )); + } + + if (count($matches) > 1) { + throw new InvalidArgumentException(sprintf( + 'Entity name "%s" is ambiguous, possible matches: "%s"', + $entityName, + implode(', ', $matches), + )); + } + + return $entityManager->getClassMetadata(current($matches)); + } + + /** + * Format the given value for console output + */ + private function formatValue(mixed $value): string + { + if ($value === '') { + return ''; + } + + if ($value === null) { + return 'Null'; + } + + if (is_bool($value)) { + return '' . ($value ? 'True' : 'False') . ''; + } + + if (empty($value)) { + return 'Empty'; + } + + if (is_array($value)) { + return json_encode( + $value, + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR, + ); + } + + if (is_object($value)) { + return sprintf('<%s>', get_debug_type($value)); + } + + if (is_scalar($value)) { + return (string) $value; + } + + throw new InvalidArgumentException(sprintf('Do not know how to format value "%s"', print_r($value, true))); + } + + /** + * Add the given label and value to the two column table output + * + * @param string $label Label for the value + * @param mixed $value A Value to show + * + * @return string[] + * @psalm-return array{0: string, 1: string} + */ + private function formatField(string $label, mixed $value): array + { + if ($value === null) { + $value = 'None'; + } + + return [sprintf('%s', $label), $this->formatValue($value)]; + } + + /** + * Format the association mappings + * + * @psalm-param array $propertyMappings + * + * @return string[][] + * @psalm-return list + */ + private function formatMappings(array $propertyMappings): array + { + $output = []; + + foreach ($propertyMappings as $propertyName => $mapping) { + $output[] = $this->formatField(sprintf(' %s', $propertyName), ''); + + foreach ((array) $mapping as $field => $value) { + $output[] = $this->formatField(sprintf(' %s', $field), $this->formatValue($value)); + } + } + + return $output; + } + + /** + * Format the entity listeners + * + * @psalm-param list $entityListeners + * + * @return string[] + * @psalm-return array{0: string, 1: string} + */ + private function formatEntityListeners(array $entityListeners): array + { + return $this->formatField('Entity listeners', array_map('get_class', $entityListeners)); + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/RunDqlCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/RunDqlCommand.php new file mode 100644 index 0000000..252151e --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/RunDqlCommand.php @@ -0,0 +1,118 @@ +setName('orm:run-dql') + ->setDescription('Executes arbitrary DQL directly from the command line') + ->addArgument('dql', InputArgument::REQUIRED, 'The DQL to execute.') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('hydrate', null, InputOption::VALUE_REQUIRED, 'Hydration mode of result set. Should be either: object, array, scalar or single-scalar.', 'object') + ->addOption('first-result', null, InputOption::VALUE_REQUIRED, 'The first result in the result set.') + ->addOption('max-result', null, InputOption::VALUE_REQUIRED, 'The maximum number of results in the result set.') + ->addOption('depth', null, InputOption::VALUE_REQUIRED, 'Dumping depth of Entity graph.', 7) + ->addOption('show-sql', null, InputOption::VALUE_NONE, 'Dump generated SQL instead of executing query') + ->setHelp(<<<'EOT' + The %command.name% command executes the given DQL query and + outputs the results: + + php %command.full_name% "SELECT u FROM App\Entity\User u" + + You can also optionally specify some additional options like what type of + hydration to use when executing the query: + + php %command.full_name% "SELECT u FROM App\Entity\User u" --hydrate=array + + Additionally you can specify the first result and maximum amount of results to + show: + + php %command.full_name% "SELECT u FROM App\Entity\User u" --first-result=0 --max-result=30 + EOT); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = new SymfonyStyle($input, $output); + + $em = $this->getEntityManager($input); + + $dql = $input->getArgument('dql'); + if ($dql === null) { + throw new RuntimeException("Argument 'dql' is required in order to execute this command correctly."); + } + + $depth = $input->getOption('depth'); + + if (! is_numeric($depth)) { + throw new LogicException("Option 'depth' must contain an integer value"); + } + + $hydrationModeName = (string) $input->getOption('hydrate'); + $hydrationMode = 'Doctrine\ORM\Query::HYDRATE_' . strtoupper(str_replace('-', '_', $hydrationModeName)); + + if (! defined($hydrationMode)) { + throw new RuntimeException(sprintf( + "Hydration mode '%s' does not exist. It should be either: object. array, scalar or single-scalar.", + $hydrationModeName, + )); + } + + $query = $em->createQuery($dql); + + $firstResult = $input->getOption('first-result'); + if ($firstResult !== null) { + if (! is_numeric($firstResult)) { + throw new LogicException("Option 'first-result' must contain an integer value"); + } + + $query->setFirstResult((int) $firstResult); + } + + $maxResult = $input->getOption('max-result'); + if ($maxResult !== null) { + if (! is_numeric($maxResult)) { + throw new LogicException("Option 'max-result' must contain an integer value"); + } + + $query->setMaxResults((int) $maxResult); + } + + if ($input->getOption('show-sql')) { + $ui->text($query->getSQL()); + + return 0; + } + + $resultSet = $query->execute([], constant($hydrationMode)); + + $ui->text(Debug::dump($resultSet, (int) $input->getOption('depth'))); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/AbstractCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/AbstractCommand.php new file mode 100644 index 0000000..b1e4460 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/AbstractCommand.php @@ -0,0 +1,39 @@ +getEntityManager($input); + + $metadatas = $em->getMetadataFactory()->getAllMetadata(); + + if (empty($metadatas)) { + $ui->getErrorStyle()->success('No Metadata Classes to process.'); + + return 0; + } + + return $this->executeSchemaCommand($input, $output, new SchemaTool($em), $metadatas, $ui); + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/CreateCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/CreateCommand.php new file mode 100644 index 0000000..69e20c6 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/CreateCommand.php @@ -0,0 +1,75 @@ +setName('orm:schema-tool:create') + ->setDescription('Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.') + ->setHelp(<<<'EOT' +Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output. + +Hint: If you have a database with tables that should not be managed +by the ORM, you can use a DBAL functionality to filter the tables and sequences down +on a global level: + + $config->setSchemaAssetsFilter(function (string|AbstractAsset $assetName): bool { + if ($assetName instanceof AbstractAsset) { + $assetName = $assetName->getName(); + } + + return !str_starts_with($assetName, 'audit_'); + }); +EOT); + } + + /** + * {@inheritDoc} + */ + protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int + { + $dumpSql = $input->getOption('dump-sql') === true; + + if ($dumpSql) { + $sqls = $schemaTool->getCreateSchemaSql($metadatas); + + foreach ($sqls as $sql) { + $ui->writeln(sprintf('%s;', $sql)); + } + + return 0; + } + + $notificationUi = $ui->getErrorStyle(); + + $notificationUi->caution('This operation should not be executed in a production environment!'); + + $notificationUi->text('Creating database schema...'); + $notificationUi->newLine(); + + $schemaTool->createSchema($metadatas); + + $notificationUi->success('Database schema created successfully!'); + + return 0; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/DropCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/DropCommand.php new file mode 100644 index 0000000..5c8253b --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/DropCommand.php @@ -0,0 +1,116 @@ +setName('orm:schema-tool:drop') + ->setDescription('Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Instead of trying to apply generated SQLs into EntityManager Storage Connection, output them.') + ->addOption('force', 'f', InputOption::VALUE_NONE, "Don't ask for the deletion of the database, but force the operation to run.") + ->addOption('full-database', null, InputOption::VALUE_NONE, 'Instead of using the Class Metadata to detect the database table schema, drop ALL assets that the database contains.') + ->setHelp(<<<'EOT' +Processes the schema and either drop the database schema of EntityManager Storage Connection or generate the SQL output. +Beware that the complete database is dropped by this command, even tables that are not relevant to your metadata model. + +Hint: If you have a database with tables that should not be managed +by the ORM, you can use a DBAL functionality to filter the tables and sequences down +on a global level: + + $config->setSchemaAssetsFilter(function (string|AbstractAsset $assetName): bool { + if ($assetName instanceof AbstractAsset) { + $assetName = $assetName->getName(); + } + + return !str_starts_with($assetName, 'audit_'); + }); +EOT); + } + + /** + * {@inheritDoc} + */ + protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int + { + $isFullDatabaseDrop = $input->getOption('full-database'); + $dumpSql = $input->getOption('dump-sql') === true; + $force = $input->getOption('force') === true; + + if ($dumpSql) { + if ($isFullDatabaseDrop) { + $sqls = $schemaTool->getDropDatabaseSQL(); + } else { + $sqls = $schemaTool->getDropSchemaSQL($metadatas); + } + + foreach ($sqls as $sql) { + $ui->writeln(sprintf('%s;', $sql)); + } + + return 0; + } + + $notificationUi = $ui->getErrorStyle(); + + if ($force) { + $notificationUi->text('Dropping database schema...'); + $notificationUi->newLine(); + + if ($isFullDatabaseDrop) { + $schemaTool->dropDatabase(); + } else { + $schemaTool->dropSchema($metadatas); + } + + $notificationUi->success('Database schema dropped successfully!'); + + return 0; + } + + $notificationUi->caution('This operation should not be executed in a production environment!'); + + if ($isFullDatabaseDrop) { + $sqls = $schemaTool->getDropDatabaseSQL(); + } else { + $sqls = $schemaTool->getDropSchemaSQL($metadatas); + } + + if (empty($sqls)) { + $notificationUi->success('Nothing to drop. The database is empty!'); + + return 0; + } + + $notificationUi->text( + [ + sprintf('The Schema-Tool would execute "%s" queries to update the database.', count($sqls)), + '', + 'Please run the operation by passing one - or both - of the following options:', + '', + sprintf(' %s --force to execute the command', $this->getName()), + sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName()), + ], + ); + + return 1; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/UpdateCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/UpdateCommand.php new file mode 100644 index 0000000..f35fc38 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -0,0 +1,147 @@ +setName($this->name) + ->setDescription('Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('complete', null, InputOption::VALUE_NONE, 'This option is a no-op, is deprecated and will be removed in 4.0') + ->addOption('dump-sql', null, InputOption::VALUE_NONE, 'Dumps the generated SQL statements to the screen (does not execute them).') + ->addOption('force', 'f', InputOption::VALUE_NONE, 'Causes the generated SQL statements to be physically executed against your database.') + ->setHelp(<<<'EOT' +The %command.name% command generates the SQL needed to +synchronize the database schema with the current mapping metadata of the +default entity manager. + +For example, if you add metadata for a new column to an entity, this command +would generate and output the SQL needed to add the new column to the database: + +%command.name% --dump-sql + +Alternatively, you can execute the generated queries: + +%command.name% --force + +If both options are specified, the queries are output and then executed: + +%command.name% --dump-sql --force + +Finally, be aware that this task will drop all database assets (e.g. tables, +etc) that are *not* described by the current metadata. In other words, without +this option, this task leaves untouched any "extra" tables that exist in the +database, but which aren't described by any metadata. + +Hint: If you have a database with tables that should not be managed +by the ORM, you can use a DBAL functionality to filter the tables and sequences down +on a global level: + + $config->setSchemaAssetsFilter(function (string|AbstractAsset $assetName): bool { + if ($assetName instanceof AbstractAsset) { + $assetName = $assetName->getName(); + } + + return !str_starts_with($assetName, 'audit_'); + }); +EOT); + } + + /** + * {@inheritDoc} + */ + protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas, SymfonyStyle $ui): int + { + $notificationUi = $ui->getErrorStyle(); + + if ($input->getOption('complete') === true) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/11354', + 'The --complete option is a no-op, is deprecated and will be removed in Doctrine ORM 4.0.', + ); + $notificationUi->warning('The --complete option is a no-op, is deprecated and will be removed in Doctrine ORM 4.0.'); + } + + $sqls = $schemaTool->getUpdateSchemaSql($metadatas); + + if (empty($sqls)) { + $notificationUi->success('Nothing to update - your database is already in sync with the current entity metadata.'); + + return 0; + } + + $dumpSql = $input->getOption('dump-sql') === true; + $force = $input->getOption('force') === true; + + if ($dumpSql) { + foreach ($sqls as $sql) { + $ui->writeln(sprintf('%s;', $sql)); + } + } + + if ($force) { + if ($dumpSql) { + $notificationUi->newLine(); + } + + $notificationUi->text('Updating database schema...'); + $notificationUi->newLine(); + + $schemaTool->updateSchema($metadatas); + + $pluralization = count($sqls) === 1 ? 'query was' : 'queries were'; + + $notificationUi->text(sprintf(' %s %s executed', count($sqls), $pluralization)); + $notificationUi->success('Database schema updated successfully!'); + } + + if ($dumpSql || $force) { + return 0; + } + + $notificationUi->caution( + [ + 'This operation should not be executed in a production environment!', + '', + 'Use the incremental update to detect changes during development and use', + 'the SQL DDL provided to manually update your database in production.', + ], + ); + + $notificationUi->text( + [ + sprintf('The Schema-Tool would execute "%s" queries to update the database.', count($sqls)), + '', + 'Please run the operation by passing one - or both - of the following options:', + '', + sprintf(' %s --force to execute the command', $this->getName()), + sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName()), + ], + ); + + return 1; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/Command/ValidateSchemaCommand.php b/vendor/doctrine/orm/src/Tools/Console/Command/ValidateSchemaCommand.php new file mode 100644 index 0000000..cffb4ce --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/Command/ValidateSchemaCommand.php @@ -0,0 +1,89 @@ +setName('orm:validate-schema') + ->setDescription('Validate the mapping files') + ->addOption('em', null, InputOption::VALUE_REQUIRED, 'Name of the entity manager to operate on') + ->addOption('skip-mapping', null, InputOption::VALUE_NONE, 'Skip the mapping validation check') + ->addOption('skip-sync', null, InputOption::VALUE_NONE, 'Skip checking if the mapping is in sync with the database') + ->addOption('skip-property-types', null, InputOption::VALUE_NONE, 'Skip checking if property types match the Doctrine types') + ->setHelp('Validate that the mapping files are correct and in sync with the database.'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $ui = (new SymfonyStyle($input, $output))->getErrorStyle(); + + $em = $this->getEntityManager($input); + $validator = new SchemaValidator($em, ! $input->getOption('skip-property-types')); + $exit = 0; + + $ui->section('Mapping'); + + if ($input->getOption('skip-mapping')) { + $ui->text('[SKIPPED] The mapping was not checked.'); + } else { + $errors = $validator->validateMapping(); + if ($errors) { + foreach ($errors as $className => $errorMessages) { + $ui->text( + sprintf( + '[FAIL] The entity-class %s mapping is invalid:', + $className, + ), + ); + + $ui->listing($errorMessages); + $ui->newLine(); + } + + ++$exit; + } else { + $ui->success('The mapping files are correct.'); + } + } + + $ui->section('Database'); + + if ($input->getOption('skip-sync')) { + $ui->text('[SKIPPED] The database was not checked for synchronicity.'); + } elseif (! $validator->schemaInSyncWithMetadata()) { + $ui->error('The database schema is not in sync with the current mapping file.'); + + if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { + $sqls = $validator->getUpdateSchemaList(); + $ui->comment(sprintf('%d schema diff(s) detected:', count($sqls))); + foreach ($sqls as $sql) { + $ui->text(sprintf(' %s;', $sql)); + } + } + + $exit += 2; + } else { + $ui->success('The database schema is in sync with the mapping files.'); + } + + return $exit; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php b/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php new file mode 100644 index 0000000..0a00483 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php @@ -0,0 +1,88 @@ +run(); + } + + /** + * Creates a console application with the given helperset and + * optional commands. + * + * @param SymfonyCommand[] $commands + * + * @throws OutOfBoundsException + */ + public static function createApplication( + EntityManagerProvider $entityManagerProvider, + array $commands = [], + ): Application { + $version = InstalledVersions::getVersion('doctrine/orm'); + assert($version !== null); + + $cli = new Application('Doctrine Command Line Interface', $version); + $cli->setCatchExceptions(true); + + self::addCommands($cli, $entityManagerProvider); + $cli->addCommands($commands); + + return $cli; + } + + public static function addCommands(Application $cli, EntityManagerProvider $entityManagerProvider): void + { + $connectionProvider = new ConnectionFromManagerProvider($entityManagerProvider); + + if (class_exists(DBALConsole\Command\ReservedWordsCommand::class)) { + $cli->add(new DBALConsole\Command\ReservedWordsCommand($connectionProvider)); + } + + $cli->addCommands( + [ + // DBAL Commands + new DBALConsole\Command\RunSqlCommand($connectionProvider), + + // ORM Commands + new Command\ClearCache\CollectionRegionCommand($entityManagerProvider), + new Command\ClearCache\EntityRegionCommand($entityManagerProvider), + new Command\ClearCache\MetadataCommand($entityManagerProvider), + new Command\ClearCache\QueryCommand($entityManagerProvider), + new Command\ClearCache\QueryRegionCommand($entityManagerProvider), + new Command\ClearCache\ResultCommand($entityManagerProvider), + new Command\SchemaTool\CreateCommand($entityManagerProvider), + new Command\SchemaTool\UpdateCommand($entityManagerProvider), + new Command\SchemaTool\DropCommand($entityManagerProvider), + new Command\GenerateProxiesCommand($entityManagerProvider), + new Command\RunDqlCommand($entityManagerProvider), + new Command\ValidateSchemaCommand($entityManagerProvider), + new Command\InfoCommand($entityManagerProvider), + new Command\MappingDescribeCommand($entityManagerProvider), + ], + ); + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider.php b/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider.php new file mode 100644 index 0000000..866589b --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider.php @@ -0,0 +1,14 @@ +entityManagerProvider->getDefaultManager()->getConnection(); + } + + public function getConnection(string $name): Connection + { + return $this->entityManagerProvider->getManager($name)->getConnection(); + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php b/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php new file mode 100644 index 0000000..ebe60c9 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php @@ -0,0 +1,31 @@ +entityManager; + } + + public function getManager(string $name): EntityManagerInterface + { + if ($name !== $this->defaultManagerName) { + throw UnknownManagerException::unknownManager($name, [$this->defaultManagerName]); + } + + return $this->entityManager; + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/UnknownManagerException.php b/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/UnknownManagerException.php new file mode 100644 index 0000000..583d909 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/EntityManagerProvider/UnknownManagerException.php @@ -0,0 +1,23 @@ + $knownManagers */ + public static function unknownManager(string $unknownManager, array $knownManagers = []): self + { + return new self(sprintf( + 'Requested unknown entity manager: %s, known managers: %s', + $unknownManager, + implode(', ', $knownManagers), + )); + } +} diff --git a/vendor/doctrine/orm/src/Tools/Console/MetadataFilter.php b/vendor/doctrine/orm/src/Tools/Console/MetadataFilter.php new file mode 100644 index 0000000..05e248c --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/MetadataFilter.php @@ -0,0 +1,92 @@ +filter = (array) $filter; + + parent::__construct($metadata); + } + + public function accept(): bool + { + if (count($this->filter) === 0) { + return true; + } + + $it = $this->getInnerIterator(); + $metadata = $it->current(); + + foreach ($this->filter as $filter) { + $pregResult = preg_match('/' . $filter . '/', $metadata->getName()); + + if ($pregResult === false) { + throw new RuntimeException( + sprintf("Error while evaluating regex '/%s/'.", $filter), + ); + } + + if ($pregResult) { + return true; + } + } + + return false; + } + + /** @return ArrayIterator */ + public function getInnerIterator(): ArrayIterator + { + $innerIterator = parent::getInnerIterator(); + + assert($innerIterator instanceof ArrayIterator); + + return $innerIterator; + } + + public function count(): int + { + return count($this->getInnerIterator()); + } +} -- cgit v1.2.3