diff --git a/Command/LoadDataFixturesDoctrineODMCommand.php b/Command/LoadDataFixturesDoctrineODMCommand.php index 3dcfcf9f..1807a7a9 100644 --- a/Command/LoadDataFixturesDoctrineODMCommand.php +++ b/Command/LoadDataFixturesDoctrineODMCommand.php @@ -7,7 +7,6 @@ use Doctrine\Bundle\MongoDBBundle\Loader\SymfonyFixturesLoaderInterface; use Doctrine\Bundle\MongoDBBundle\ManagerRegistry; use Doctrine\Common\DataFixtures\Executor\MongoDBExecutor; -use Doctrine\Common\DataFixtures\Loader; use Doctrine\Common\DataFixtures\Purger\MongoDBPurger; use RuntimeException; use Symfony\Component\Console\Input\InputInterface; @@ -15,12 +14,9 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\HttpKernel\KernelInterface; -use function class_exists; use function implode; use function sprintf; -use function trigger_deprecation; /** * Load data fixtures from bundles. @@ -29,22 +25,16 @@ */ class LoadDataFixturesDoctrineODMCommand extends DoctrineODMCommand { - public function __construct(?ManagerRegistry $registry = null, ?KernelInterface $kernel = null, private ?SymfonyFixturesLoaderInterface $fixturesLoader = null) + public function __construct(ManagerRegistry $registry, private SymfonyFixturesLoaderInterface $fixturesLoader) { parent::__construct($registry); } - public function isEnabled(): bool - { - return parent::isEnabled() && class_exists(Loader::class); - } - protected function configure(): void { $this ->setName('doctrine:mongodb:fixtures:load') ->setDescription('Load data fixtures to your database.') - ->addOption('services', null, InputOption::VALUE_NONE, 'Use services as fixtures') ->addOption('group', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Only load fixtures that belong to this group (use with --services)') ->addOption('append', null, InputOption::VALUE_NONE, 'Append the data fixtures instead of flushing the database first.') ->addOption('dm', null, InputOption::VALUE_REQUIRED, 'The document manager to use for this command.') @@ -57,14 +47,9 @@ protected function configure(): void php %command.full_name% --append +You can also choose to load only fixtures that live in a certain group: -Alternatively, you can also load fixture services instead of files. Fixture services are tagged with `doctrine.fixture.odm.mongodb`. -Using `--services` will be the default behaviour in 5.0. -When loading fixture services, you can also choose to load only fixtures that live in a certain group: -`php %command.full_name% --group=group1 --services` - - - + php %command.full_name% --group=group1 EOT ); } @@ -74,15 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dm = $this->getManagerRegistry()->getManager($input->getOption('dm')); $ui = new SymfonyStyle($input, $output); - if ($input->getOption('services')) { - trigger_deprecation( - 'doctrine/mongodb-odm-bundle', - '4.0', - 'The "services" option to the "%s" command is deprecated and will be dropped in DoctrineMongoDBBundle 5.0.', - $this->getName() - ); - } - if ($input->isInteractive() && ! $input->getOption('append')) { $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('Careful, database will be purged. Do you want to continue (y/N) ?', false); @@ -92,10 +68,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - if (! $this->fixturesLoader) { - throw new RuntimeException('Cannot use fixture services without injecting a fixtures loader.'); - } - $groups = $input->getOption('group'); $fixtures = $this->fixturesLoader->getFixtures($groups); if (! $fixtures) { diff --git a/DependencyInjection/DoctrineMongoDBExtension.php b/DependencyInjection/DoctrineMongoDBExtension.php index 7921dbf6..4d948580 100644 --- a/DependencyInjection/DoctrineMongoDBExtension.php +++ b/DependencyInjection/DoctrineMongoDBExtension.php @@ -6,6 +6,7 @@ use Doctrine\Bundle\MongoDBBundle\Attribute\AsDocumentListener; use Doctrine\Bundle\MongoDBBundle\Attribute\MapDocument; +use Doctrine\Bundle\MongoDBBundle\Command\LoadDataFixturesDoctrineODMCommand; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\FixturesCompilerPass; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass; use Doctrine\Bundle\MongoDBBundle\EventSubscriber\EventSubscriberInterface; @@ -98,6 +99,7 @@ public function load(array $configs, ContainerBuilder $container): void ->addTag(FixturesCompilerPass::FIXTURE_TAG); } else { $container->removeDefinition('doctrine_mongodb.odm.symfony.fixtures.loader'); + $container->removeDefinition(LoadDataFixturesDoctrineODMCommand::class); } // load the connections diff --git a/Loader/SymfonyFixturesLoaderInterface.php b/Loader/SymfonyFixturesLoaderInterface.php index 7656e511..13078b08 100644 --- a/Loader/SymfonyFixturesLoaderInterface.php +++ b/Loader/SymfonyFixturesLoaderInterface.php @@ -9,11 +9,11 @@ interface SymfonyFixturesLoaderInterface { /** - * Add multple fixtures + * Add multiple fixtures * * @internal * - * @param array $fixtures + * @param list $fixtures */ public function addFixtures(array $fixtures); diff --git a/Resources/config/mongodb.xml b/Resources/config/mongodb.xml index 27cb3bd7..9317d7b0 100644 --- a/Resources/config/mongodb.xml +++ b/Resources/config/mongodb.xml @@ -75,8 +75,7 @@ - - + diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index e8523d94..c496959b 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -11,4 +11,5 @@ UPGRADE FROM 4.x to 5.0 removed without replacement. * The `Doctrine\Bundle\MongoDBBundle\Command\DoctrineODMCommand` class is now `@internal`, you should not extend from this class. -* Remove support of Annotation mapping, you should use Attributes or XML instead. +* Remove support of Annotation mapping, you should use Attributes or XML instead. +* Remove `--service` option from `doctrine:mongodb:fixtures:load` command