diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f29b0053..3fd9c98b 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -7,20 +7,15 @@ use Doctrine\ODM\MongoDB\Configuration as ODMConfiguration; use Doctrine\ODM\MongoDB\Repository\DefaultGridFSRepository; use Doctrine\ODM\MongoDB\Repository\DocumentRepository; -use LogicException; -use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; -use function class_parents; use function count; -use function in_array; use function is_array; use function is_string; use function json_decode; use function preg_match; -use function sprintf; /** * FrameworkExtension configuration structure. @@ -84,15 +79,11 @@ public function getConfigTreeBuilder() ->scalarNode('persistent_collection_dir')->defaultValue('%kernel.cache_dir%/doctrine/odm/mongodb/PersistentCollections')->end() ->scalarNode('auto_generate_persistent_collection_classes')->defaultValue(ODMConfiguration::AUTOGENERATE_NEVER)->end() ->scalarNode('fixture_loader') - ->defaultValue(ContainerAwareLoader::class) - ->beforeNormalization() - ->ifTrue(static function ($v) { - return ! ($v === ContainerAwareLoader::class || in_array(ContainerAwareLoader::class, class_parents($v))); - }) - ->then(static function ($v) { - throw new LogicException(sprintf('The %s class is not a subclass of the ContainerAwareLoader', $v)); - }) - ->end() + ->setDeprecated( + 'doctrine/mongodb-odm-bundle', + '4.7', + 'The "fixture_loader" option is deprecated and will be dropped in doctrine/mongodb-odm-bundle 5.0.', + ) ->end() ->scalarNode('default_document_manager')->end() ->scalarNode('default_connection')->end() diff --git a/DependencyInjection/DoctrineMongoDBExtension.php b/DependencyInjection/DoctrineMongoDBExtension.php index c2ec3532..602a33f2 100644 --- a/DependencyInjection/DoctrineMongoDBExtension.php +++ b/DependencyInjection/DoctrineMongoDBExtension.php @@ -96,9 +96,6 @@ public function load(array $configs, ContainerBuilder $container) $config = $this->overrideParameters($config, $container); if (class_exists(DataFixturesLoader::class)) { - // set the fixtures loader - $container->setParameter('doctrine_mongodb.odm.fixture_loader', $config['fixture_loader']); - // Autowiring fixture loader $container->registerForAutoconfiguration(ODMFixtureInterface::class) ->addTag(FixturesCompilerPass::FIXTURE_TAG); diff --git a/Resources/doc/config.rst b/Resources/doc/config.rst index f79afc8c..7e5f19c9 100644 --- a/Resources/doc/config.rst +++ b/Resources/doc/config.rst @@ -618,7 +618,6 @@ Full Default Configuration default_document_manager: ~ default_connection: ~ default_database: default - fixture_loader: Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader .. code-block:: xml diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index d76e0605..a647d431 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Configuration; +use Doctrine\Bundle\MongoDBBundle\Loader\SymfonyFixturesLoader; use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\Filter\BasicFilter; use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\Filter\ComplexFilter; use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\Filter\DisabledFilter; @@ -13,9 +14,8 @@ use Doctrine\ODM\MongoDB\Configuration as ODMConfiguration; use Doctrine\ODM\MongoDB\Repository\DefaultGridFSRepository; use Doctrine\ODM\MongoDB\Repository\DocumentRepository; -use LogicException; use PHPUnit\Framework\TestCase; -use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\Util\XmlUtils; @@ -26,6 +26,8 @@ class ConfigurationTest extends TestCase { + use ExpectDeprecationTrait; + public function testDefaults(): void { $processor = new Processor(); @@ -33,7 +35,6 @@ public function testDefaults(): void $options = $processor->processConfiguration($configuration, []); $defaults = [ - 'fixture_loader' => ContainerAwareLoader::class, 'auto_generate_hydrator_classes' => false, 'auto_generate_proxy_classes' => ODMConfiguration::AUTOGENERATE_EVAL, 'auto_generate_persistent_collection_classes' => ODMConfiguration::AUTOGENERATE_NEVER, @@ -66,7 +67,6 @@ public function testFullConfiguration(array $config): void $options = $processor->processConfiguration($configuration, [$config]); $expected = [ - 'fixture_loader' => ContainerAwareLoader::class, 'auto_generate_hydrator_classes' => 1, 'auto_generate_proxy_classes' => ODMConfiguration::AUTOGENERATE_FILE_NOT_EXISTS, 'auto_generate_persistent_collection_classes' => ODMConfiguration::AUTOGENERATE_EVAL, @@ -517,27 +517,18 @@ public function testNullReplicaSetValue(): void $this->assertFalse(array_key_exists('replicaSet', $processedConfig['connections']['conn1']['options'])); } - /** @dataProvider provideExceptionConfiguration */ - public function testFixtureLoaderValidation(array $config): void + /** @group legacy */ + public function testFixtureLoaderDeprecated(): void { + $config = [ + 'fixture_loader' => SymfonyFixturesLoader::class, + ]; + $processor = new Processor(); $configuration = new Configuration(); - $this->expectException(LogicException::class); - $processor->processConfiguration($configuration, [$config]); - } - - /** @return array */ - public static function provideExceptionConfiguration(): array - { - $yaml = Yaml::parse(file_get_contents(__DIR__ . '/Fixtures/config/yml/exception.yml')); - $yaml = $yaml['doctrine_mongodb']; - $xml = XmlUtils::loadFile(__DIR__ . '/Fixtures/config/xml/exception.xml'); - $xml = XmlUtils::convertDomElementToArray($xml->getElementsByTagName('config')->item(0)); + $this->expectDeprecation('Since doctrine/mongodb-odm-bundle 4.7: The "fixture_loader" option is deprecated and will be dropped in doctrine/mongodb-odm-bundle 5.0.'); - return [ - [$yaml], - [$xml], - ]; + $processor->processConfiguration($configuration, [$config]); } } diff --git a/Tests/DependencyInjection/Fixtures/config/xml/exception.xml b/Tests/DependencyInjection/Fixtures/config/xml/exception.xml deleted file mode 100644 index 07d4ed12..00000000 --- a/Tests/DependencyInjection/Fixtures/config/xml/exception.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/Tests/DependencyInjection/Fixtures/config/xml/full.xml b/Tests/DependencyInjection/Fixtures/config/xml/full.xml index c3a1abb9..2479cb05 100644 --- a/Tests/DependencyInjection/Fixtures/config/xml/full.xml +++ b/Tests/DependencyInjection/Fixtures/config/xml/full.xml @@ -7,7 +7,6 @@ http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">