vendor/doctrine/doctrine-bundle/DependencyInjection/Configuration.php line 274

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection;
  3. use Doctrine\Common\Proxy\AbstractProxyFactory;
  4. use Doctrine\ORM\EntityManager;
  5. use Doctrine\ORM\EntityRepository;
  6. use Doctrine\ORM\Mapping\ClassMetadataFactory;
  7. use ReflectionClass;
  8. use Symfony\Component\Config\Definition\BaseNode;
  9. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  10. use Symfony\Component\Config\Definition\Builder\NodeDefinition;
  11. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  12. use Symfony\Component\Config\Definition\ConfigurationInterface;
  13. use Symfony\Component\DependencyInjection\Exception\LogicException;
  14. use function array_intersect_key;
  15. use function array_key_exists;
  16. use function array_keys;
  17. use function array_pop;
  18. use function assert;
  19. use function class_exists;
  20. use function constant;
  21. use function count;
  22. use function defined;
  23. use function implode;
  24. use function in_array;
  25. use function is_array;
  26. use function is_bool;
  27. use function is_int;
  28. use function is_string;
  29. use function key;
  30. use function method_exists;
  31. use function reset;
  32. use function sprintf;
  33. use function strlen;
  34. use function strpos;
  35. use function strtoupper;
  36. use function substr;
  37. use function trigger_deprecation;
  38. /**
  39.  * This class contains the configuration information for the bundle
  40.  *
  41.  * This information is solely responsible for how the different configuration
  42.  * sections are normalized, and merged.
  43.  */
  44. class Configuration implements ConfigurationInterface
  45. {
  46.     /** @var bool */
  47.     private $debug;
  48.     /** @param bool $debug Whether to use the debug mode */
  49.     public function __construct(bool $debug)
  50.     {
  51.         $this->debug $debug;
  52.     }
  53.     public function getConfigTreeBuilder(): TreeBuilder
  54.     {
  55.         $treeBuilder = new TreeBuilder('doctrine');
  56.         $rootNode    $treeBuilder->getRootNode();
  57.         $this->addDbalSection($rootNode);
  58.         $this->addOrmSection($rootNode);
  59.         return $treeBuilder;
  60.     }
  61.     /**
  62.      * Add DBAL section to configuration tree
  63.      */
  64.     private function addDbalSection(ArrayNodeDefinition $node): void
  65.     {
  66.         $node
  67.             ->children()
  68.             ->arrayNode('dbal')
  69.                 ->beforeNormalization()
  70.                     ->ifTrue(static function ($v) {
  71.                         return is_array($v) && ! array_key_exists('connections'$v) && ! array_key_exists('connection'$v);
  72.                     })
  73.                     ->then(static function ($v) {
  74.                         // Key that should not be rewritten to the connection config
  75.                         $excludedKeys = ['default_connection' => true'types' => true'type' => true];
  76.                         $connection   = [];
  77.                         foreach ($v as $key => $value) {
  78.                             if (isset($excludedKeys[$key])) {
  79.                                 continue;
  80.                             }
  81.                             $connection[$key] = $v[$key];
  82.                             unset($v[$key]);
  83.                         }
  84.                         $v['default_connection'] = isset($v['default_connection']) ? (string) $v['default_connection'] : 'default';
  85.                         $v['connections']        = [$v['default_connection'] => $connection];
  86.                         return $v;
  87.                     })
  88.                 ->end()
  89.                 ->children()
  90.                     ->scalarNode('default_connection')->end()
  91.                 ->end()
  92.                 ->fixXmlConfig('type')
  93.                 ->children()
  94.                     ->arrayNode('types')
  95.                         ->useAttributeAsKey('name')
  96.                         ->prototype('array')
  97.                             ->beforeNormalization()
  98.                                 ->ifString()
  99.                                 ->then(static function ($v) {
  100.                                     return ['class' => $v];
  101.                                 })
  102.                             ->end()
  103.                             ->children()
  104.                                 ->scalarNode('class')->isRequired()->end()
  105.                                 ->booleanNode('commented')
  106.                                     ->setDeprecated(
  107.                                         ...$this->getDeprecationMsg('The doctrine-bundle type commenting features were removed; the corresponding config parameter was deprecated in 2.0 and will be dropped in 3.0.''2.0')
  108.                                     )
  109.                                 ->end()
  110.                             ->end()
  111.                         ->end()
  112.                     ->end()
  113.                 ->end()
  114.                 ->fixXmlConfig('connection')
  115.                 ->append($this->getDbalConnectionsNode())
  116.             ->end();
  117.     }
  118.     /**
  119.      * Return the dbal connections node
  120.      */
  121.     private function getDbalConnectionsNode(): ArrayNodeDefinition
  122.     {
  123.         $treeBuilder = new TreeBuilder('connections');
  124.         $node        $treeBuilder->getRootNode();
  125.         $connectionNode $node
  126.             ->requiresAtLeastOneElement()
  127.             ->useAttributeAsKey('name')
  128.             ->prototype('array');
  129.         assert($connectionNode instanceof ArrayNodeDefinition);
  130.         $this->configureDbalDriverNode($connectionNode);
  131.         $collationKey defined('Doctrine\DBAL\Connection::PARAM_ASCII_STR_ARRAY')
  132.             ? 'collate'
  133.             'collation';
  134.         $connectionNode
  135.             ->fixXmlConfig('option')
  136.             ->fixXmlConfig('mapping_type')
  137.             ->fixXmlConfig('slave')
  138.             ->fixXmlConfig('replica')
  139.             ->fixXmlConfig('shard')
  140.             ->fixXmlConfig('default_table_option')
  141.             ->children()
  142.                 ->scalarNode('driver')->defaultValue('pdo_mysql')->end()
  143.                 ->scalarNode('platform_service')->end()
  144.                 ->booleanNode('auto_commit')->end()
  145.                 ->scalarNode('schema_filter')->end()
  146.                 ->booleanNode('logging')->defaultValue($this->debug)->end()
  147.                 ->booleanNode('profiling')->defaultValue($this->debug)->end()
  148.                 ->booleanNode('profiling_collect_backtrace')
  149.                     ->defaultValue(false)
  150.                     ->info('Enables collecting backtraces when profiling is enabled')
  151.                 ->end()
  152.                 ->booleanNode('profiling_collect_schema_errors')
  153.                     ->defaultValue(true)
  154.                     ->info('Enables collecting schema errors when profiling is enabled')
  155.                 ->end()
  156.                 ->scalarNode('server_version')->end()
  157.                 ->scalarNode('driver_class')->end()
  158.                 ->scalarNode('wrapper_class')->end()
  159.                 ->scalarNode('shard_manager_class')
  160.                     ->setDeprecated(
  161.                         ...$this->getDeprecationMsg('The "shard_manager_class" configuration is deprecated and not supported anymore using DBAL 3.''2.7')
  162.                     )
  163.                 ->end()
  164.                 ->scalarNode('shard_choser')
  165.                     ->setDeprecated(
  166.                         ...$this->getDeprecationMsg('The "shard_choser" configuration is deprecated and not supported anymore using DBAL 3.''2.7')
  167.                     )
  168.                 ->end()
  169.                 ->scalarNode('shard_choser_service')
  170.                     ->setDeprecated(
  171.                         ...$this->getDeprecationMsg('The "shard_choser_service" configuration is deprecated and not supported anymore using DBAL 3.''2.7')
  172.                     )
  173.                 ->end()
  174.                 ->booleanNode('keep_slave')
  175.                     ->setDeprecated(
  176.                         ...$this->getDeprecationMsg('The "keep_slave" configuration key is deprecated since doctrine-bundle 2.2. Use the "keep_replica" configuration key instead.''2.2')
  177.                     )
  178.                 ->end()
  179.                 ->booleanNode('keep_replica')->end()
  180.                 ->arrayNode('options')
  181.                     ->useAttributeAsKey('key')
  182.                     ->prototype('variable')->end()
  183.                 ->end()
  184.                 ->arrayNode('mapping_types')
  185.                     ->useAttributeAsKey('name')
  186.                     ->prototype('scalar')->end()
  187.                 ->end()
  188.                 ->arrayNode('default_table_options')
  189.                 ->info(sprintf(
  190.                     "This option is used by the schema-tool and affects generated SQL. Possible keys include 'charset','%s', and 'engine'.",
  191.                     $collationKey
  192.                 ))
  193.                     ->useAttributeAsKey('name')
  194.                     ->prototype('scalar')->end()
  195.                 ->end()
  196.             ->end();
  197.         // dbal < 2.11
  198.         $slaveNode $connectionNode
  199.             ->children()
  200.                 ->arrayNode('slaves')
  201.                     ->setDeprecated(
  202.                         ...$this->getDeprecationMsg('The "slaves" configuration key will be renamed to "replicas" in doctrine-bundle 3.0. "slaves" is deprecated since doctrine-bundle 2.2.''2.2')
  203.                     )
  204.                     ->useAttributeAsKey('name')
  205.                     ->prototype('array');
  206.         $this->configureDbalDriverNode($slaveNode);
  207.         // dbal >= 2.11
  208.         $replicaNode $connectionNode
  209.             ->children()
  210.                 ->arrayNode('replicas')
  211.                     ->useAttributeAsKey('name')
  212.                     ->prototype('array');
  213.         $this->configureDbalDriverNode($replicaNode);
  214.         $shardNode $connectionNode
  215.             ->children()
  216.                 ->arrayNode('shards')
  217.                     ->setDeprecated(
  218.                         ...$this->getDeprecationMsg('The "shards" configuration is deprecated and not supported anymore using DBAL 3.''2.7')
  219.                     )
  220.                     ->prototype('array');
  221.         $shardNode
  222.             ->children()
  223.                 ->integerNode('id')
  224.                     ->min(1)
  225.                     ->isRequired()
  226.                 ->end()
  227.             ->end();
  228.         $this->configureDbalDriverNode($shardNode);
  229.         return $node;
  230.     }
  231.     /**
  232.      * Adds config keys related to params processed by the DBAL drivers
  233.      *
  234.      * These keys are available for replica configurations too.
  235.      */
  236.     private function configureDbalDriverNode(ArrayNodeDefinition $node): void
  237.     {
  238.         $node
  239.             ->validate()
  240.             ->always(static function (array $values) {
  241.                 if (! isset($values['url'])) {
  242.                     return $values;
  243.                 }
  244.                 $urlConflictingOptions = ['host' => true'port' => true'user' => true'password' => true'path' => true'dbname' => true'unix_socket' => true'memory' => true];
  245.                 $urlConflictingValues  array_keys(array_intersect_key($values$urlConflictingOptions));
  246.                 if ($urlConflictingValues) {
  247.                     $tail count($urlConflictingValues) > sprintf('or "%s" options'array_pop($urlConflictingValues)) : 'option';
  248.                     trigger_deprecation(
  249.                         'doctrine/doctrine-bundle',
  250.                         '2.4',
  251.                         'Setting the "doctrine.dbal.%s" %s while the "url" one is defined is deprecated',
  252.                         implode('", "'$urlConflictingValues),
  253.                         $tail
  254.                     );
  255.                 }
  256.                 return $values;
  257.             })
  258.             ->end()
  259.             ->children()
  260.                 ->scalarNode('url')->info('A URL with connection information; any parameter value parsed from this string will override explicitly set parameters')->end()
  261.                 ->scalarNode('dbname')->end()
  262.                 ->scalarNode('host')->info('Defaults to "localhost" at runtime.')->end()
  263.                 ->scalarNode('port')->info('Defaults to null at runtime.')->end()
  264.                 ->scalarNode('user')->info('Defaults to "root" at runtime.')->end()
  265.                 ->scalarNode('password')->info('Defaults to null at runtime.')->end()
  266.                 ->booleanNode('override_url')->setDeprecated(...$this->getDeprecationMsg('The "doctrine.dbal.override_url" configuration key is deprecated.''2.4'))->end()
  267.                 ->scalarNode('dbname_suffix')->end()
  268.                 ->scalarNode('application_name')->end()
  269.                 ->scalarNode('charset')->end()
  270.                 ->scalarNode('path')->end()
  271.                 ->booleanNode('memory')->end()
  272.                 ->scalarNode('unix_socket')->info('The unix socket to use for MySQL')->end()
  273.                 ->booleanNode('persistent')->info('True to use as persistent connection for the ibm_db2 driver')->end()
  274.                 ->scalarNode('protocol')->info('The protocol to use for the ibm_db2 driver (default to TCPIP if omitted)')->end()
  275.                 ->booleanNode('service')
  276.                     ->info('True to use SERVICE_NAME as connection parameter instead of SID for Oracle')
  277.                 ->end()
  278.                 ->scalarNode('servicename')
  279.                     ->info(
  280.                         'Overrules dbname parameter if given and used as SERVICE_NAME or SID connection parameter ' .
  281.                         'for Oracle depending on the service parameter.'
  282.                     )
  283.                 ->end()
  284.                 ->scalarNode('sessionMode')
  285.                     ->info('The session mode to use for the oci8 driver')
  286.                 ->end()
  287.                 ->scalarNode('server')
  288.                     ->info('The name of a running database server to connect to for SQL Anywhere.')
  289.                 ->end()
  290.                 ->scalarNode('default_dbname')
  291.                     ->info(
  292.                         'Override the default database (postgres) to connect to for PostgreSQL connexion.'
  293.                     )
  294.                 ->end()
  295.                 ->scalarNode('sslmode')
  296.                     ->info(
  297.                         'Determines whether or with what priority a SSL TCP/IP connection will be negotiated with ' .
  298.                         'the server for PostgreSQL.'
  299.                     )
  300.                 ->end()
  301.                 ->scalarNode('sslrootcert')
  302.                     ->info(
  303.                         'The name of a file containing SSL certificate authority (CA) certificate(s). ' .
  304.                         'If the file exists, the server\'s certificate will be verified to be signed by one of these authorities.'
  305.                     )
  306.                 ->end()
  307.                 ->scalarNode('sslcert')
  308.                     ->info(
  309.                         'The path to the SSL client certificate file for PostgreSQL.'
  310.                     )
  311.                 ->end()
  312.                 ->scalarNode('sslkey')
  313.                     ->info(
  314.                         'The path to the SSL client key file for PostgreSQL.'
  315.                     )
  316.                 ->end()
  317.                 ->scalarNode('sslcrl')
  318.                     ->info(
  319.                         'The file name of the SSL certificate revocation list for PostgreSQL.'
  320.                     )
  321.                 ->end()
  322.                 ->booleanNode('pooled')->info('True to use a pooled server with the oci8/pdo_oracle driver')->end()
  323.                 ->booleanNode('MultipleActiveResultSets')->info('Configuring MultipleActiveResultSets for the pdo_sqlsrv driver')->end()
  324.                 ->booleanNode('use_savepoints')->info('Use savepoints for nested transactions')->end()
  325.                 ->scalarNode('instancename')
  326.                 ->info(
  327.                     'Optional parameter, complete whether to add the INSTANCE_NAME parameter in the connection.' .
  328.                     ' It is generally used to connect to an Oracle RAC server to select the name' .
  329.                     ' of a particular instance.'
  330.                 )
  331.                 ->end()
  332.                 ->scalarNode('connectstring')
  333.                 ->info(
  334.                     'Complete Easy Connect connection descriptor, see https://docs.oracle.com/database/121/NETAG/naming.htm.' .
  335.                     'When using this option, you will still need to provide the user and password parameters, but the other ' .
  336.                     'parameters will no longer be used. Note that when using this parameter, the getHost and getPort methods' .
  337.                     ' from Doctrine\DBAL\Connection will no longer function as expected.'
  338.                 )
  339.                 ->end()
  340.             ->end()
  341.             ->beforeNormalization()
  342.                 ->ifTrue(static function ($v) {
  343.                     return ! isset($v['sessionMode']) && isset($v['session_mode']);
  344.                 })
  345.                 ->then(static function ($v) {
  346.                     $v['sessionMode'] = $v['session_mode'];
  347.                     unset($v['session_mode']);
  348.                     return $v;
  349.                 })
  350.             ->end()
  351.             ->beforeNormalization()
  352.                 ->ifTrue(static function ($v) {
  353.                     return ! isset($v['MultipleActiveResultSets']) && isset($v['multiple_active_result_sets']);
  354.                 })
  355.                 ->then(static function ($v) {
  356.                     $v['MultipleActiveResultSets'] = $v['multiple_active_result_sets'];
  357.                     unset($v['multiple_active_result_sets']);
  358.                     return $v;
  359.                 })
  360.             ->end();
  361.     }
  362.     /**
  363.      * Add the ORM section to configuration tree
  364.      */
  365.     private function addOrmSection(ArrayNodeDefinition $node): void
  366.     {
  367.         $node
  368.             ->children()
  369.                 ->arrayNode('orm')
  370.                     ->beforeNormalization()
  371.                         ->ifTrue(static function ($v) {
  372.                             if (! empty($v) && ! class_exists(EntityManager::class)) {
  373.                                 throw new LogicException('The doctrine/orm package is required when the doctrine.orm config is set.');
  374.                             }
  375.                             return $v === null || (is_array($v) && ! array_key_exists('entity_managers'$v) && ! array_key_exists('entity_manager'$v));
  376.                         })
  377.                         ->then(static function ($v) {
  378.                             $v = (array) $v;
  379.                             // Key that should not be rewritten to the connection config
  380.                             $excludedKeys  = [
  381.                                 'default_entity_manager' => true,
  382.                                 'auto_generate_proxy_classes' => true,
  383.                                 'proxy_dir' => true,
  384.                                 'proxy_namespace' => true,
  385.                                 'resolve_target_entities' => true,
  386.                                 'resolve_target_entity' => true,
  387.                             ];
  388.                             $entityManager = [];
  389.                             foreach ($v as $key => $value) {
  390.                                 if (isset($excludedKeys[$key])) {
  391.                                     continue;
  392.                                 }
  393.                                 $entityManager[$key] = $v[$key];
  394.                                 unset($v[$key]);
  395.                             }
  396.                             $v['default_entity_manager'] = isset($v['default_entity_manager']) ? (string) $v['default_entity_manager'] : 'default';
  397.                             $v['entity_managers']        = [$v['default_entity_manager'] => $entityManager];
  398.                             return $v;
  399.                         })
  400.                     ->end()
  401.                     ->children()
  402.                         ->scalarNode('default_entity_manager')->end()
  403.                         ->scalarNode('auto_generate_proxy_classes')->defaultValue(false)
  404.                             ->info('Auto generate mode possible values are: "NEVER", "ALWAYS", "FILE_NOT_EXISTS", "EVAL", "FILE_NOT_EXISTS_OR_CHANGED"')
  405.                             ->validate()
  406.                                 ->ifTrue(function ($v) {
  407.                                     $generationModes $this->getAutoGenerateModes();
  408.                                     if (is_int($v) && in_array($v$generationModes['values']/*array(0, 1, 2, 3)*/)) {
  409.                                         return false;
  410.                                     }
  411.                                     if (is_bool($v)) {
  412.                                         return false;
  413.                                     }
  414.                                     if (is_string($v)) {
  415.                                         if (in_array(strtoupper($v), $generationModes['names']/*array('NEVER', 'ALWAYS', 'FILE_NOT_EXISTS', 'EVAL', 'FILE_NOT_EXISTS_OR_CHANGED')*/)) {
  416.                                             return false;
  417.                                         }
  418.                                     }
  419.                                     return true;
  420.                                 })
  421.                                 ->thenInvalid('Invalid auto generate mode value %s')
  422.                             ->end()
  423.                             ->validate()
  424.                                 ->ifString()
  425.                                 ->then(static function ($v) {
  426.                                     return constant('Doctrine\Common\Proxy\AbstractProxyFactory::AUTOGENERATE_' strtoupper($v));
  427.                                 })
  428.                             ->end()
  429.                         ->end()
  430.                         ->scalarNode('proxy_dir')->defaultValue('%kernel.cache_dir%/doctrine/orm/Proxies')->end()
  431.                         ->scalarNode('proxy_namespace')->defaultValue('Proxies')->end()
  432.                     ->end()
  433.                     ->fixXmlConfig('entity_manager')
  434.                     ->append($this->getOrmEntityManagersNode())
  435.                     ->fixXmlConfig('resolve_target_entity''resolve_target_entities')
  436.                     ->append($this->getOrmTargetEntityResolverNode())
  437.                 ->end()
  438.             ->end();
  439.     }
  440.     /**
  441.      * Return ORM target entity resolver node
  442.      */
  443.     private function getOrmTargetEntityResolverNode(): NodeDefinition
  444.     {
  445.         $treeBuilder = new TreeBuilder('resolve_target_entities');
  446.         $node        $treeBuilder->getRootNode();
  447.         $node
  448.             ->useAttributeAsKey('interface')
  449.             ->prototype('scalar')
  450.                 ->cannotBeEmpty()
  451.             ->end();
  452.         return $node;
  453.     }
  454.     /**
  455.      * Return ORM entity listener node
  456.      */
  457.     private function getOrmEntityListenersNode(): NodeDefinition
  458.     {
  459.         $treeBuilder = new TreeBuilder('entity_listeners');
  460.         $node        $treeBuilder->getRootNode();
  461.         $normalizer = static function ($mappings) {
  462.             $entities = [];
  463.             foreach ($mappings as $entityClass => $mapping) {
  464.                 $listeners = [];
  465.                 foreach ($mapping as $listenerClass => $listenerEvent) {
  466.                     $events = [];
  467.                     foreach ($listenerEvent as $eventType => $eventMapping) {
  468.                         if ($eventMapping === null) {
  469.                             $eventMapping = [null];
  470.                         }
  471.                         foreach ($eventMapping as $method) {
  472.                             $events[] = [
  473.                                 'type' => $eventType,
  474.                                 'method' => $method,
  475.                             ];
  476.                         }
  477.                     }
  478.                     $listeners[] = [
  479.                         'class' => $listenerClass,
  480.                         'event' => $events,
  481.                     ];
  482.                 }
  483.                 $entities[] = [
  484.                     'class' => $entityClass,
  485.                     'listener' => $listeners,
  486.                 ];
  487.             }
  488.             return ['entities' => $entities];
  489.         };
  490.         $node
  491.             ->beforeNormalization()
  492.                 // Yaml normalization
  493.                 ->ifTrue(static function ($v) {
  494.                     return is_array(reset($v)) && is_string(key(reset($v)));
  495.                 })
  496.                 ->then($normalizer)
  497.             ->end()
  498.             ->fixXmlConfig('entity''entities')
  499.             ->children()
  500.                 ->arrayNode('entities')
  501.                     ->useAttributeAsKey('class')
  502.                     ->prototype('array')
  503.                         ->fixXmlConfig('listener')
  504.                         ->children()
  505.                             ->arrayNode('listeners')
  506.                                 ->useAttributeAsKey('class')
  507.                                 ->prototype('array')
  508.                                     ->fixXmlConfig('event')
  509.                                     ->children()
  510.                                         ->arrayNode('events')
  511.                                             ->prototype('array')
  512.                                                 ->children()
  513.                                                     ->scalarNode('type')->end()
  514.                                                     ->scalarNode('method')->defaultNull()->end()
  515.                                                 ->end()
  516.                                             ->end()
  517.                                         ->end()
  518.                                     ->end()
  519.                                 ->end()
  520.                             ->end()
  521.                         ->end()
  522.                     ->end()
  523.                 ->end()
  524.             ->end();
  525.         return $node;
  526.     }
  527.     /**
  528.      * Return ORM entity manager node
  529.      */
  530.     private function getOrmEntityManagersNode(): ArrayNodeDefinition
  531.     {
  532.         $treeBuilder = new TreeBuilder('entity_managers');
  533.         $node        $treeBuilder->getRootNode();
  534.         $node
  535.             ->requiresAtLeastOneElement()
  536.             ->useAttributeAsKey('name')
  537.             ->prototype('array')
  538.                 ->addDefaultsIfNotSet()
  539.                 ->append($this->getOrmCacheDriverNode('query_cache_driver'))
  540.                 ->append($this->getOrmCacheDriverNode('metadata_cache_driver'))
  541.                 ->append($this->getOrmCacheDriverNode('result_cache_driver'))
  542.                 ->append($this->getOrmEntityListenersNode())
  543.                 ->fixXmlConfig('schema_ignore_class''schema_ignore_classes')
  544.                 ->children()
  545.                     ->scalarNode('connection')->end()
  546.                     ->scalarNode('class_metadata_factory_name')->defaultValue(ClassMetadataFactory::class)->end()
  547.                     ->scalarNode('default_repository_class')->defaultValue(EntityRepository::class)->end()
  548.                     ->scalarNode('auto_mapping')->defaultFalse()->end()
  549.                     ->scalarNode('naming_strategy')->defaultValue('doctrine.orm.naming_strategy.default')->end()
  550.                     ->scalarNode('quote_strategy')->defaultValue('doctrine.orm.quote_strategy.default')->end()
  551.                     ->scalarNode('entity_listener_resolver')->defaultNull()->end()
  552.                     ->scalarNode('repository_factory')->defaultValue('doctrine.orm.container_repository_factory')->end()
  553.                     ->arrayNode('schema_ignore_classes')
  554.                         ->prototype('scalar')->end()
  555.                     ->end()
  556.                 ->end()
  557.                 ->children()
  558.                     ->arrayNode('second_level_cache')
  559.                         ->children()
  560.                             ->append($this->getOrmCacheDriverNode('region_cache_driver'))
  561.                             ->scalarNode('region_lock_lifetime')->defaultValue(60)->end()
  562.                             ->booleanNode('log_enabled')->defaultValue($this->debug)->end()
  563.                             ->scalarNode('region_lifetime')->defaultValue(3600)->end()
  564.                             ->booleanNode('enabled')->defaultValue(true)->end()
  565.                             ->scalarNode('factory')->end()
  566.                         ->end()
  567.                         ->fixXmlConfig('region')
  568.                         ->children()
  569.                             ->arrayNode('regions')
  570.                                 ->useAttributeAsKey('name')
  571.                                 ->prototype('array')
  572.                                     ->children()
  573.                                         ->append($this->getOrmCacheDriverNode('cache_driver'))
  574.                                         ->scalarNode('lock_path')->defaultValue('%kernel.cache_dir%/doctrine/orm/slc/filelock')->end()
  575.                                         ->scalarNode('lock_lifetime')->defaultValue(60)->end()
  576.                                         ->scalarNode('type')->defaultValue('default')->end()
  577.                                         ->scalarNode('lifetime')->defaultValue(0)->end()
  578.                                         ->scalarNode('service')->end()
  579.                                         ->scalarNode('name')->end()
  580.                                     ->end()
  581.                                 ->end()
  582.                             ->end()
  583.                         ->end()
  584.                         ->fixXmlConfig('logger')
  585.                         ->children()
  586.                             ->arrayNode('loggers')
  587.                                 ->useAttributeAsKey('name')
  588.                                 ->prototype('array')
  589.                                     ->children()
  590.                                         ->scalarNode('name')->end()
  591.                                         ->scalarNode('service')->end()
  592.                                     ->end()
  593.                                 ->end()
  594.                             ->end()
  595.                         ->end()
  596.                     ->end()
  597.                 ->end()
  598.                 ->fixXmlConfig('hydrator')
  599.                 ->children()
  600.                     ->arrayNode('hydrators')
  601.                         ->useAttributeAsKey('name')
  602.                         ->prototype('scalar')->end()
  603.                     ->end()
  604.                 ->end()
  605.                 ->fixXmlConfig('mapping')
  606.                 ->children()
  607.                     ->arrayNode('mappings')
  608.                         ->useAttributeAsKey('name')
  609.                         ->prototype('array')
  610.                             ->beforeNormalization()
  611.                                 ->ifString()
  612.                                 ->then(static function ($v) {
  613.                                     return ['type' => $v];
  614.                                 })
  615.                             ->end()
  616.                             ->treatNullLike([])
  617.                             ->treatFalseLike(['mapping' => false])
  618.                             ->performNoDeepMerging()
  619.                             ->children()
  620.                                 ->scalarNode('mapping')->defaultValue(true)->end()
  621.                                 ->scalarNode('type')->end()
  622.                                 ->scalarNode('dir')->end()
  623.                                 ->scalarNode('alias')->end()
  624.                                 ->scalarNode('prefix')->end()
  625.                                 ->booleanNode('is_bundle')->end()
  626.                             ->end()
  627.                         ->end()
  628.                     ->end()
  629.                     ->arrayNode('dql')
  630.                         ->fixXmlConfig('string_function')
  631.                         ->fixXmlConfig('numeric_function')
  632.                         ->fixXmlConfig('datetime_function')
  633.                         ->children()
  634.                             ->arrayNode('string_functions')
  635.                                 ->useAttributeAsKey('name')
  636.                                 ->prototype('scalar')->end()
  637.                             ->end()
  638.                             ->arrayNode('numeric_functions')
  639.                                 ->useAttributeAsKey('name')
  640.                                 ->prototype('scalar')->end()
  641.                             ->end()
  642.                             ->arrayNode('datetime_functions')
  643.                                 ->useAttributeAsKey('name')
  644.                                 ->prototype('scalar')->end()
  645.                             ->end()
  646.                         ->end()
  647.                     ->end()
  648.                 ->end()
  649.                 ->fixXmlConfig('filter')
  650.                 ->children()
  651.                     ->arrayNode('filters')
  652.                         ->info('Register SQL Filters in the entity manager')
  653.                         ->useAttributeAsKey('name')
  654.                         ->prototype('array')
  655.                             ->beforeNormalization()
  656.                                 ->ifString()
  657.                                 ->then(static function ($v) {
  658.                                     return ['class' => $v];
  659.                                 })
  660.                             ->end()
  661.                             ->beforeNormalization()
  662.                                 // The content of the XML node is returned as the "value" key so we need to rename it
  663.                                 ->ifTrue(static function ($v) {
  664.                                     return is_array($v) && isset($v['value']);
  665.                                 })
  666.                                 ->then(static function ($v) {
  667.                                     $v['class'] = $v['value'];
  668.                                     unset($v['value']);
  669.                                     return $v;
  670.                                 })
  671.                             ->end()
  672.                             ->fixXmlConfig('parameter')
  673.                             ->children()
  674.                                 ->scalarNode('class')->isRequired()->end()
  675.                                 ->booleanNode('enabled')->defaultFalse()->end()
  676.                                 ->arrayNode('parameters')
  677.                                     ->useAttributeAsKey('name')
  678.                                     ->prototype('variable')->end()
  679.                                 ->end()
  680.                             ->end()
  681.                         ->end()
  682.                     ->end()
  683.                 ->end()
  684.             ->end();
  685.         return $node;
  686.     }
  687.     /**
  688.      * Return a ORM cache driver node for an given entity manager
  689.      */
  690.     private function getOrmCacheDriverNode(string $name): ArrayNodeDefinition
  691.     {
  692.         $treeBuilder = new TreeBuilder($name);
  693.         $node        $treeBuilder->getRootNode();
  694.         $node
  695.             ->beforeNormalization()
  696.                 ->ifString()
  697.                 ->then(static function ($v): array {
  698.                     return ['type' => $v];
  699.                 })
  700.             ->end()
  701.             ->children()
  702.                 ->scalarNode('type')->defaultNull()->end()
  703.                 ->scalarNode('id')->end()
  704.                 ->scalarNode('pool')->end()
  705.             ->end();
  706.         if ($name !== 'metadata_cache_driver') {
  707.             $node->addDefaultsIfNotSet();
  708.         }
  709.         return $node;
  710.     }
  711.     /**
  712.      * Find proxy auto generate modes for their names and int values
  713.      *
  714.      * @return array{names: list<string>, values: list<int>}
  715.      */
  716.     private function getAutoGenerateModes(): array
  717.     {
  718.         $constPrefix 'AUTOGENERATE_';
  719.         $prefixLen   strlen($constPrefix);
  720.         $refClass    = new ReflectionClass(AbstractProxyFactory::class);
  721.         $constsArray $refClass->getConstants();
  722.         $namesArray  = [];
  723.         $valuesArray = [];
  724.         foreach ($constsArray as $key => $value) {
  725.             if (strpos($key$constPrefix) !== 0) {
  726.                 continue;
  727.             }
  728.             $namesArray[]  = substr($key$prefixLen);
  729.             $valuesArray[] = (int) $value;
  730.         }
  731.         return [
  732.             'names' => $namesArray,
  733.             'values' => $valuesArray,
  734.         ];
  735.     }
  736.     /**
  737.      * Returns the correct deprecation param's as an array for setDeprecated.
  738.      *
  739.      * Symfony/Config v5.1 introduces a deprecation notice when calling
  740.      * setDeprecation() with less than 3 args and the getDeprecation method was
  741.      * introduced at the same time. By checking if getDeprecation() exists,
  742.      * we can determine the correct param count to use when calling setDeprecated.
  743.      *
  744.      * @return list<string>|array{0:string, 1: numeric-string, string}
  745.      */
  746.     private function getDeprecationMsg(string $messagestring $version): array
  747.     {
  748.         if (method_exists(BaseNode::class, 'getDeprecation')) {
  749.             return [
  750.                 'doctrine/doctrine-bundle',
  751.                 $version,
  752.                 $message,
  753.             ];
  754.         }
  755.         return [$message];
  756.     }
  757. }