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

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