vendor/pimcore/pimcore/bundles/CoreBundle/DependencyInjection/Configuration.php line 52

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  * @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. namespace Pimcore\Bundle\CoreBundle\DependencyInjection;
  15. use Pimcore\Bundle\CoreBundle\DependencyInjection\Config\Processor\PlaceholderProcessor;
  16. use Pimcore\Cache\Pool\Redis;
  17. use Pimcore\Storage\Redis\ConnectionFactory;
  18. use Pimcore\Targeting\Storage\CookieStorage;
  19. use Pimcore\Targeting\Storage\TargetingStorageInterface;
  20. use Pimcore\Workflow\EventSubscriber\ChangePublishedStateSubscriber;
  21. use Pimcore\Workflow\EventSubscriber\NotificationSubscriber;
  22. use Pimcore\Workflow\Notification\NotificationEmailService;
  23. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  24. use Symfony\Component\Config\Definition\Builder\NodeDefinition;
  25. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  26. use Symfony\Component\Config\Definition\ConfigurationInterface;
  27. class Configuration implements ConfigurationInterface
  28. {
  29.     /**
  30.      * @var PlaceholderProcessor
  31.      */
  32.     private $placeholderProcessor;
  33.     private $placeholders = [];
  34.     public function __construct()
  35.     {
  36.         $this->placeholderProcessor = new PlaceholderProcessor();
  37.         $this->placeholders = [];
  38.     }
  39.     /**
  40.      * Generates the configuration tree builder.
  41.      *
  42.      * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
  43.      */
  44.     public function getConfigTreeBuilder()
  45.     {
  46.         $treeBuilder = new TreeBuilder();
  47.         $rootNode $treeBuilder->root('pimcore');
  48.         $rootNode->addDefaultsIfNotSet();
  49.         $rootNode->ignoreExtraKeys();
  50.         $rootNode
  51.             ->children()
  52.                 ->arrayNode('error_handling')
  53.                     ->addDefaultsIfNotSet()
  54.                     ->children()
  55.                         ->booleanNode('render_error_document')
  56.                             ->info('Render error document in case of an error instead of showing Symfony\'s error page')
  57.                             ->defaultTrue()
  58.                             ->beforeNormalization()
  59.                                 ->ifString()
  60.                                 ->then(function ($v) {
  61.                                     return (bool)$v;
  62.                                 })
  63.                             ->end()
  64.                         ->end()
  65.                     ->end()
  66.                 ->end()
  67.                 ->arrayNode('bundles')
  68.                     ->addDefaultsIfNotSet()
  69.                     ->children()
  70.                         ->arrayNode('search_paths')
  71.                             ->prototype('scalar')->end()
  72.                         ->end()
  73.                         ->booleanNode('handle_composer')
  74.                             ->defaultTrue()
  75.                         ->end()
  76.                     ->end()
  77.                 ->end()
  78.                 ->arrayNode('flags')
  79.                     ->info('Generic map for feature flags')
  80.                     ->prototype('scalar')->end()
  81.                 ->end()
  82.                 ->arrayNode('translations')
  83.                     ->addDefaultsIfNotSet()
  84.                     ->children()
  85.                         ->booleanNode('case_insensitive')
  86.                             ->beforeNormalization()
  87.                                 ->ifString()
  88.                                 ->then(function ($v) {
  89.                                     return (bool)$v;
  90.                                 })
  91.                             ->end()
  92.                             ->info('Force Pimcore translations to NOT be case sensitive. This only applies to translations set via Pimcore\'s translator (e.g. website translations)')
  93.                             ->defaultFalse()
  94.                         ->end()
  95.                         ->arrayNode('debugging')
  96.                             ->info('If debugging is enabled, the translator will return the plain translation key instead of the translated message.')
  97.                             ->addDefaultsIfNotSet()
  98.                             ->canBeDisabled()
  99.                             ->children()
  100.                                 ->scalarNode('parameter')
  101.                                     ->defaultValue('pimcore_debug_translations')
  102.                                 ->end()
  103.                             ->end()
  104.                         ->end()
  105.                         ->arrayNode('data_object')
  106.                             ->addDefaultsIfNotSet()
  107.                             ->children()
  108.                                 ->arrayNode('translation_extractor')
  109.                                     ->children()
  110.                                         ->arrayNode('attributes')
  111.                                             ->info('Can be used to restrict the extracted localized fields (e.g. used by XLIFF exporter in the Pimcore backend)')
  112.                                             ->prototype('array')
  113.                                                 ->prototype('scalar')->end()
  114.                                             ->end()
  115.                                             ->example(
  116.                                                 [
  117.                                                     'Product' => ['name''description'],
  118.                                                     'Brand' => ['name'],
  119.                                                 ]
  120.                                             )
  121.                                         ->end()
  122.                                     ->end()
  123.                                 ->end()
  124.                             ->end()
  125.                         ->end()
  126.                     ->end()
  127.                 ->end()
  128.                 ->arrayNode('maps')
  129.                     ->addDefaultsIfNotSet()
  130.                     ->children()
  131.                         ->scalarNode('tile_layer_url_template')
  132.                             ->defaultValue('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png')
  133.                         ->end()
  134.                         ->scalarNode('geocoding_url_template')
  135.                             ->defaultValue('https://nominatim.openstreetmap.org/search?q={q}&addressdetails=1&format=json&limit=1')
  136.                         ->end()
  137.                         ->scalarNode('reverse_geocoding_url_template')
  138.                             ->defaultValue('https://nominatim.openstreetmap.org/reverse?format=json&lat={lat}&lon={lon}&addressdetails=1')
  139.                         ->end()
  140.                     ->end()
  141.                 ->end()
  142.             ->end();
  143.         $this->addGeneralNode($rootNode);
  144.         $this->addMaintenanceNode($rootNode);
  145.         $this->addServicesNode($rootNode);
  146.         $this->addObjectsNode($rootNode);
  147.         $this->addAssetNode($rootNode);
  148.         $this->addDocumentsNode($rootNode);
  149.         $this->addEncryptionNode($rootNode);
  150.         $this->addModelsNode($rootNode);
  151.         $this->addRoutingNode($rootNode);
  152.         $this->addCacheNode($rootNode);
  153.         $this->addContextNode($rootNode);
  154.         $this->addAdminNode($rootNode);
  155.         $this->addWebProfilerNode($rootNode);
  156.         $this->addSecurityNode($rootNode);
  157.         $this->addEmailNode($rootNode);
  158.         $this->addNewsletterNode($rootNode);
  159.         $this->addCustomReportsNode($rootNode);
  160.         $this->addMigrationsNode($rootNode);
  161.         $this->addTargetingNode($rootNode);
  162.         $this->addSitemapsNode($rootNode);
  163.         $this->addMimeNode($rootNode);
  164.         $this->addWorkflowNode($rootNode);
  165.         $this->addHttpClientNode($rootNode);
  166.         $this->addApplicationLogNode($rootNode);
  167.         return $treeBuilder;
  168.     }
  169.     /**
  170.      * Add maintenance config
  171.      *
  172.      * @param ArrayNodeDefinition $rootNode
  173.      */
  174.     private function addMaintenanceNode(ArrayNodeDefinition $rootNode)
  175.     {
  176.         $rootNode
  177.             ->children()
  178.             ->arrayNode('maintenance')
  179.             ->addDefaultsIfNotSet()
  180.             ->children()
  181.                 ->arrayNode('housekeeping')
  182.                 ->addDefaultsIfNotSet()
  183.                 ->children()
  184.                     ->integerNode('cleanup_tmp_files_atime_older_than')
  185.                         ->defaultValue(7776000// 90 days
  186.                     ->end()
  187.                     ->integerNode('cleanup_profiler_files_atime_older_than')
  188.                         ->defaultValue(1800)
  189.                     ->end()
  190.         ;
  191.     }
  192.     /**
  193.      * Add general config
  194.      *
  195.      * @param ArrayNodeDefinition $rootNode
  196.      */
  197.     private function addGeneralNode(ArrayNodeDefinition $rootNode)
  198.     {
  199.         $rootNode
  200.             ->children()
  201.             ->arrayNode('general')
  202.             ->ignoreExtraKeys()
  203.             ->addDefaultsIfNotSet()
  204.             ->children()
  205.                 ->scalarNode('timezone')
  206.                     ->defaultValue('Europe/Berlin')
  207.                 ->end()
  208.                 ->scalarNode('path_variable')
  209.                     ->defaultNull()
  210.                 ->end()
  211.                 ->scalarNode('domain')
  212.                     ->defaultNull()
  213.                 ->end()
  214.                 ->booleanNode('redirect_to_maindomain')
  215.                     ->beforeNormalization()
  216.                         ->ifString()
  217.                         ->then(function ($v) {
  218.                             return (bool)$v;
  219.                         })
  220.                     ->end()
  221.                     ->defaultFalse()
  222.                 ->end()
  223.                 ->scalarNode('language')
  224.                     ->defaultValue('en')
  225.                 ->end()
  226.                 ->scalarNode('valid_languages')
  227.                     ->defaultValue('en')
  228.                 ->end()
  229.                 ->arrayNode('fallback_languages')
  230.                     ->performNoDeepMerging()
  231.                     ->beforeNormalization()
  232.                     ->ifArray()
  233.                         ->then(function ($v) {
  234.                             return $v;
  235.                         })
  236.                     ->end()
  237.                     ->prototype('scalar')
  238.                     ->end()
  239.                 ->end()
  240.                 ->scalarNode('default_language')
  241.                     ->defaultValue('en')
  242.                 ->end()
  243.                 ->booleanNode('disable_usage_statistics')
  244.                     ->beforeNormalization()
  245.                         ->ifString()
  246.                         ->then(function ($v) {
  247.                             return (bool)$v;
  248.                         })
  249.                     ->end()
  250.                     ->defaultFalse()
  251.                 ->end()
  252.                 ->booleanNode('debug_admin_translations')
  253.                     ->beforeNormalization()
  254.                         ->ifString()
  255.                         ->then(function ($v) {
  256.                             return (bool)$v;
  257.                         })
  258.                     ->end()
  259.                     ->defaultFalse()
  260.                 ->end()
  261.                 ->scalarNode('instance_identifier')
  262.                     ->defaultNull()->end()
  263.                 ->booleanNode('show_cookie_notice')
  264.                     ->setDeprecated('The cookie bar will be removed in Pimcore 7')
  265.                     ->beforeNormalization()
  266.                         ->ifString()
  267.                         ->then(function ($v) {
  268.                             return (bool)$v;
  269.                         })
  270.                     ->end()
  271.                     ->defaultFalse()
  272.                 ->end()
  273.             ->end();
  274.     }
  275.     /**
  276.      * @param ArrayNodeDefinition $rootNode
  277.      */
  278.     private function addServicesNode(ArrayNodeDefinition $rootNode)
  279.     {
  280.         $rootNode
  281.             ->children()
  282.             ->arrayNode('services')
  283.                 ->children()
  284.                     ->arrayNode('google')
  285.                     ->children()
  286.                         ->scalarNode('client_id')
  287.                             ->defaultNull()
  288.                         ->end()
  289.                         ->scalarNode('email')
  290.                             ->defaultNull()
  291.                         ->end()
  292.                         ->scalarNode('simple_api_key')
  293.                             ->defaultNull()
  294.                         ->end()
  295.                         ->scalarNode('browser_api_key')
  296.                             ->defaultNull()
  297.                         ->end()
  298.                     ->end()
  299.                     ->end()
  300.                 ->end()
  301.             ->end()
  302.             ->arrayNode('webservice')
  303.                 ->canBeEnabled()
  304.             ->end();
  305.     }
  306.     /**
  307.      * @param ArrayNodeDefinition $rootNode
  308.      */
  309.     private function addModelsNode(ArrayNodeDefinition $rootNode)
  310.     {
  311.         $rootNode
  312.             ->children()
  313.                 ->arrayNode('models')
  314.                     ->addDefaultsIfNotSet()
  315.                     ->children()
  316.                         ->arrayNode('class_overrides')
  317.                             ->useAttributeAsKey('name')
  318.                             ->prototype('scalar');
  319.     }
  320.     /**
  321.      * @param ArrayNodeDefinition $rootNode
  322.      */
  323.     private function addHttpClientNode(ArrayNodeDefinition $rootNode)
  324.     {
  325.         $rootNode
  326.             ->children()
  327.                 ->arrayNode('httpclient')
  328.                 ->addDefaultsIfNotSet()
  329.                     ->children()
  330.                         ->scalarNode('adapter')
  331.                             ->defaultValue('Socket')
  332.                         ->end()
  333.                         ->scalarNode('proxy_host')
  334.                             ->defaultNull()
  335.                         ->end()
  336.                         ->scalarNode('proxy_port')
  337.                             ->defaultNull()
  338.                         ->end()
  339.                         ->scalarNode('proxy_user')
  340.                             ->defaultNull()
  341.                         ->end()
  342.                         ->scalarNode('proxy_pass')
  343.                             ->defaultNull()
  344.                         ->end()
  345.                     ->end()
  346.                 ->end()
  347.             ->end();
  348.     }
  349.     /**
  350.      * @param ArrayNodeDefinition $rootNode
  351.      */
  352.     private function addApplicationLogNode(ArrayNodeDefinition $rootNode)
  353.     {
  354.         $rootNode
  355.             ->children()
  356.                 ->arrayNode('applicationlog')
  357.                 ->addDefaultsIfNotSet()
  358.                     ->children()
  359.                         ->arrayNode('mail_notification')
  360.                             ->children()
  361.                                 ->booleanNode('send_log_summary')
  362.                                     ->beforeNormalization()
  363.                                         ->ifString()
  364.                                         ->then(function ($v) {
  365.                                             return (bool)$v;
  366.                                         })
  367.                                     ->end()
  368.                                     ->defaultFalse()
  369.                                 ->end()
  370.                                 ->scalarNode('filter_priority')
  371.                                     ->defaultNull()
  372.                                 ->end()
  373.                                 ->scalarNode('mail_receiver')
  374.                                 ->end()
  375.                             ->end()
  376.                         ->end()
  377.                         ->scalarNode('archive_treshold')
  378.                             ->defaultValue('')
  379.                         ->end()
  380.                         ->scalarNode('archive_alternative_database')
  381.                             ->defaultValue('')
  382.                         ->end()
  383.                     ->end()
  384.             ->end();
  385.     }
  386.     /**
  387.      * Add asset specific extension config
  388.      *
  389.      * @param ArrayNodeDefinition $rootNode
  390.      */
  391.     private function addAssetNode(ArrayNodeDefinition $rootNode)
  392.     {
  393.         $assetsNode $rootNode
  394.             ->children()
  395.                 ->arrayNode('assets')
  396.                 ->ignoreExtraKeys()
  397.                 ->addDefaultsIfNotSet()
  398.                 ->children()
  399.                     ->scalarNode('preview_image_thumbnail')
  400.                         ->defaultNull()
  401.                         ->end()
  402.                     ->scalarNode('default_upload_path')
  403.                         ->defaultValue('_default_upload_bucket')
  404.                         ->end()
  405.                     ->integerNode('tree_paging_limit')
  406.                         ->defaultValue(100)
  407.                         ->end()
  408.                     ->arrayNode('image')
  409.                         ->addDefaultsIfNotSet()
  410.                         ->children()
  411.                             ->arrayNode('low_quality_image_preview')
  412.                                 ->addDefaultsIfNotSet()
  413.                                 ->canBeDisabled()
  414.                                 ->children()
  415.                                     ->scalarNode('generator')
  416.                                     ->defaultNull()
  417.                                     ->end()
  418.                                 ->end()
  419.                             ->end()
  420.                             ->arrayNode('focal_point_detection')
  421.                                 ->addDefaultsIfNotSet()
  422.                                 ->canBeDisabled()
  423.                             ->end()
  424.                             ->arrayNode('thumbnails')
  425.                                 ->addDefaultsIfNotSet()
  426.                                 ->children()
  427.                                     ->booleanNode('webp_auto_support')
  428.                                         ->beforeNormalization()
  429.                                             ->ifString()
  430.                                             ->then(function ($v) {
  431.                                                 return (bool)$v;
  432.                                             })
  433.                                         ->end()
  434.                                         ->defaultTrue()
  435.                                     ->end()
  436.                                     ->booleanNode('auto_clear_temp_files')
  437.                                         ->beforeNormalization()
  438.                                             ->ifString()
  439.                                             ->then(function ($v) {
  440.                                                 return (bool)$v;
  441.                                             })
  442.                                         ->end()
  443.                                         ->defaultTrue()
  444.                                     ->end()
  445.                                 ->end()
  446.                             ->end()
  447.                         ->end()
  448.                     ->end()
  449.                     ->arrayNode('video')
  450.                         ->addDefaultsIfNotSet()
  451.                         ->children()
  452.                             ->arrayNode('thumbnails')
  453.                                 ->addDefaultsIfNotSet()
  454.                                 ->children()
  455.                                     ->booleanNode('auto_clear_temp_files')
  456.                                     ->defaultTrue()
  457.                                     ->end()
  458.                                 ->end()
  459.                             ->end()
  460.                         ->end()
  461.                     ->end()
  462.                     ->arrayNode('versions')
  463.                         ->addDefaultsIfNotSet()
  464.                         ->children()
  465.                             ->scalarNode('days')
  466.                                 ->defaultNull()
  467.                             ->end()
  468.                             ->scalarNode('steps')
  469.                                 ->defaultNull()
  470.                             ->end()
  471.                             ->booleanNode('use_hardlinks')
  472.                                 ->beforeNormalization()
  473.                                     ->ifString()
  474.                                     ->then(function ($v) {
  475.                                         return (bool)$v;
  476.                                     })
  477.                                 ->end()
  478.                                 ->defaultTrue()
  479.                             ->end()
  480.                         ->end()
  481.                     ->end()
  482.                     ->scalarNode('icc_rgb_profile')
  483.                         ->defaultNull()
  484.                     ->end()
  485.                     ->scalarNode('icc_cmyk_profile')
  486.                         ->defaultNull()
  487.                     ->end()
  488.                     ->booleanNode('hide_edit_image')
  489.                         ->defaultFalse()
  490.                     ->end()
  491.                     ->booleanNode('disable_tree_preview')
  492.                         ->defaultTrue()
  493.                     ->end()
  494.                 ->end();
  495.         $assetsNode
  496.             ->children()
  497.                 ->arrayNode('metadata')
  498.                 ->addDefaultsIfNotSet()
  499.                     ->children()
  500.                         ->arrayNode('class_definitions')
  501.                             ->children()
  502.                                 ->arrayNode('data')
  503.                                     ->children()
  504.                                         ->arrayNode('map')
  505.                                             ->useAttributeAsKey('name')
  506.                                             ->prototype('scalar')->end()
  507.                                         ->end()
  508.                                         ->arrayNode('prefixes')
  509.                                             ->prototype('scalar')->end()
  510.                                         ->end()
  511.                                     ->end()
  512.                                 ->end()
  513.                             ->end()
  514.                         ->end();
  515.     }
  516.     /**
  517.      * Add object specific extension config
  518.      *
  519.      * @param ArrayNodeDefinition $rootNode
  520.      */
  521.     private function addObjectsNode(ArrayNodeDefinition $rootNode)
  522.     {
  523.         $objectsNode $rootNode
  524.             ->children()
  525.                 ->arrayNode('objects')
  526.                     ->ignoreExtraKeys()
  527.                     ->addDefaultsIfNotSet()
  528.                     ->children()
  529.                         ->integerNode('tree_paging_limit')
  530.                             ->defaultValue(30)
  531.                         ->end()
  532.                         ->arrayNode('versions')
  533.                             ->children()
  534.                                 ->scalarNode('days')->defaultNull()->end()
  535.                                 ->scalarNode('steps')->defaultNull()->end()
  536.                             ->end()
  537.                         ->end()
  538.                     ->end();
  539.         $classDefinitionsNode $objectsNode
  540.             ->children()
  541.                 ->arrayNode('class_definitions')
  542.                     ->addDefaultsIfNotSet();
  543.         $this->addImplementationLoaderNode($classDefinitionsNode'data');
  544.         $this->addImplementationLoaderNode($classDefinitionsNode'layout');
  545.     }
  546.     /**
  547.      * Add encryption specific extension config
  548.      *
  549.      * @param ArrayNodeDefinition $rootNode
  550.      */
  551.     private function addEncryptionNode(ArrayNodeDefinition $rootNode)
  552.     {
  553.         $encryptionNode $rootNode
  554.             ->children()
  555.             ->arrayNode('encryption')->addDefaultsIfNotSet();
  556.         $encryptionNode
  557.             ->children()
  558.             ->scalarNode('secret')->defaultNull();
  559.     }
  560.     /**
  561.      * Add document specific extension config
  562.      *
  563.      * @param ArrayNodeDefinition $rootNode
  564.      */
  565.     private function addDocumentsNode(ArrayNodeDefinition $rootNode)
  566.     {
  567.         $documentsNode $rootNode
  568.             ->children()
  569.                 ->arrayNode('documents')
  570.                     ->ignoreExtraKeys()
  571.                     ->addDefaultsIfNotSet();
  572.         $this->addImplementationLoaderNode($documentsNode'tags');
  573.         $documentsNode
  574.             ->children()
  575.                 ->arrayNode('versions')
  576.                     ->children()
  577.                         ->scalarNode('days')
  578.                             ->defaultNull()
  579.                         ->end()
  580.                         ->scalarNode('steps')
  581.                             ->defaultNull()
  582.                         ->end()
  583.                     ->end()
  584.                 ->end()
  585.                 ->arrayNode('error_pages')
  586.                     ->children()
  587.                         ->scalarNode('default')
  588.                             ->defaultNull()
  589.                         ->end()
  590.                     ->end()
  591.                 ->end()
  592.                 ->booleanNode('create_redirect_when_moved')
  593.                     ->setDeprecated('The "%node%" option is deprecated and not used anymore, it is just there for compatibility.')
  594.                     ->beforeNormalization()
  595.                         ->ifString()
  596.                         ->then(function ($v) {
  597.                             return (bool)$v;
  598.                         })
  599.                     ->end()
  600.                     ->defaultFalse()
  601.                 ->end()
  602.                 ->scalarNode('allow_trailing_slash')
  603.                     ->defaultValue('no')
  604.                 ->end()
  605.                 ->booleanNode('generate_preview')
  606.                     ->beforeNormalization()
  607.                         ->ifString()
  608.                         ->then(function ($v) {
  609.                             return (bool)$v;
  610.                         })
  611.                     ->end()
  612.                     ->defaultFalse()
  613.                 ->end()
  614.                 ->integerNode('tree_paging_limit')
  615.                     ->defaultValue(50)
  616.                 ->end()
  617.                 ->arrayNode('editables')
  618.                     ->addDefaultsIfNotSet()
  619.                     ->children()
  620.                         ->enumNode('naming_strategy')
  621.                             ->info('Sets naming strategy used to build editable names')
  622.                             ->values(['legacy''nested'])
  623.                             ->defaultValue('nested')
  624.                         ->end()
  625.                     ->end()
  626.                 ->end()
  627.                 ->arrayNode('areas')
  628.                     ->addDefaultsIfNotSet()
  629.                     ->children()
  630.                         ->booleanNode('autoload')
  631.                             ->beforeNormalization()
  632.                                 ->ifString()
  633.                                 ->then(function ($v) {
  634.                                     return (bool)$v;
  635.                                 })
  636.                             ->end()
  637.                             ->defaultTrue()
  638.                         ->end()
  639.                     ->end()
  640.                 ->end()
  641.                 ->arrayNode('newsletter')
  642.                     ->addDefaultsIfNotSet()
  643.                     ->children()
  644.                         ->scalarNode('defaultUrlPrefix')
  645.                             ->defaultNull()
  646.                         ->end()
  647.                     ->end()
  648.                 ->end()
  649.                 ->arrayNode('web_to_print')
  650.                     ->addDefaultsIfNotSet()
  651.                         ->children()
  652.                             ->scalarNode('pdf_creation_php_memory_limit')
  653.                             ->defaultValue('2048M')
  654.                         ->end()
  655.                     ->end()
  656.                 ->end()
  657.             ->end();
  658.     }
  659.     /**
  660.      * Add implementation node config (map, prefixes)
  661.      *
  662.      * @param ArrayNodeDefinition $node
  663.      * @param string $name
  664.      */
  665.     private function addImplementationLoaderNode(ArrayNodeDefinition $node$name)
  666.     {
  667.         $node
  668.             ->children()
  669.                 ->arrayNode($name)
  670.                     ->addDefaultsIfNotSet()
  671.                     ->children()
  672.                         ->arrayNode('map')
  673.                             ->useAttributeAsKey('name')
  674.                             ->prototype('scalar')->end()
  675.                         ->end()
  676.                         ->arrayNode('prefixes')
  677.                             ->prototype('scalar')->end()
  678.                         ->end()
  679.                     ->end()
  680.                 ->end()
  681.             ->end();
  682.     }
  683.     private function addRoutingNode(ArrayNodeDefinition $rootNode)
  684.     {
  685.         $rootNode
  686.             ->children()
  687.                 ->arrayNode('routing')
  688.                     ->addDefaultsIfNotSet()
  689.                     ->children()
  690.                         ->arrayNode('defaults')
  691.                             ->addDefaultsIfNotSet()
  692.                             ->children()
  693.                                 ->scalarNode('bundle')
  694.                                     ->defaultValue('AppBundle')
  695.                                 ->end()
  696.                                 ->scalarNode('controller')
  697.                                     ->defaultValue('Default')
  698.                                 ->end()
  699.                                 ->scalarNode('action')
  700.                                     ->defaultValue('default')
  701.                                 ->end()
  702.                             ->end()
  703.                         ->end()
  704.                         ->arrayNode('static')
  705.                             ->addDefaultsIfNotSet()
  706.                             ->children()
  707.                                 ->arrayNode('locale_params')
  708.                                     ->info('Route params from this list will be mapped to _locale if _locale is not set explicitely')
  709.                                     ->prototype('scalar')
  710.                                     ->defaultValue([])
  711.                                 ->end()
  712.                             ->end()
  713.                         ->end()
  714.                     ->end()
  715.                 ->end();
  716.     }
  717.     /**
  718.      * Add context config
  719.      *
  720.      * @param ArrayNodeDefinition $rootNode
  721.      */
  722.     private function addContextNode(ArrayNodeDefinition $rootNode)
  723.     {
  724.         $contextNode $rootNode->children()
  725.             ->arrayNode('context');
  726.         /** @var ArrayNodeDefinition|NodeDefinition $prototype */
  727.         $prototype $contextNode->prototype('array');
  728.         // define routes child on each context entry
  729.         $this->addRoutesChild($prototype'routes');
  730.     }
  731.     /**
  732.      * Add admin config
  733.      *
  734.      * @param ArrayNodeDefinition $rootNode
  735.      */
  736.     private function addAdminNode(ArrayNodeDefinition $rootNode)
  737.     {
  738.         $adminNode $rootNode->children()
  739.             ->arrayNode('admin')
  740.             ->ignoreExtraKeys()
  741.             ->addDefaultsIfNotSet();
  742.         // add session attribute bag config
  743.         $this->addAdminSessionAttributeBags($adminNode);
  744.         // unauthenticated routes won't be double checked for authentication in AdminControllerListener
  745.         $this->addRoutesChild($adminNode'unauthenticated_routes');
  746.         $adminNode
  747.             ->children()
  748.                 ->arrayNode('translations')
  749.                     ->addDefaultsIfNotSet()
  750.                     ->children()
  751.                         ->scalarNode('path')->defaultNull()->end()
  752.                     ->end()
  753.                 ->end()
  754.             ->end();
  755.     }
  756.     /**
  757.      * @param ArrayNodeDefinition $adminNode
  758.      */
  759.     private function addAdminSessionAttributeBags(ArrayNodeDefinition $adminNode)
  760.     {
  761.         // Normalizes session bag config. Allows the following formats (all formats will be
  762.         // normalized to the third format.
  763.         //
  764.         // attribute_bags:
  765.         //      - foo
  766.         //      - bar
  767.         //
  768.         // attribute_bags:
  769.         //      foo: _foo
  770.         //      bar: _bar
  771.         //
  772.         // attribute_bags:
  773.         //      foo:
  774.         //          storage_key: _foo
  775.         //      bar:
  776.         //          storage_key: _bar
  777.         $normalizers = [
  778.             'assoc' => function (array $array) {
  779.                 $result = [];
  780.                 foreach ($array as $name => $value) {
  781.                     if (null === $value) {
  782.                         $value = [
  783.                             'storage_key' => '_' $name
  784.                         ];
  785.                     }
  786.                     if (is_string($value)) {
  787.                         $value = [
  788.                             'storage_key' => $value
  789.                         ];
  790.                     }
  791.                     $result[$name] = $value;
  792.                 }
  793.                 return $result;
  794.             },
  795.             'sequential' => function (array $array) {
  796.                 $result = [];
  797.                 foreach ($array as $name) {
  798.                     $result[$name] = [
  799.                         'storage_key' => '_' $name
  800.                     ];
  801.                 }
  802.                 return $result;
  803.             }
  804.         ];
  805.         $adminNode
  806.             ->children()
  807.                 ->arrayNode('session')
  808.                     ->addDefaultsIfNotSet()
  809.                     ->children()
  810.                         ->arrayNode('attribute_bags')
  811.                             ->useAttributeAsKey('name')
  812.                             ->beforeNormalization()
  813.                                 ->ifArray()->then(function ($v) use ($normalizers) {
  814.                                     if (isAssocArray($v)) {
  815.                                         return $normalizers['assoc']($v);
  816.                                     } else {
  817.                                         return $normalizers['sequential']($v);
  818.                                     }
  819.                                 })
  820.                             ->end()
  821.                             ->example([
  822.                                 ['foo''bar'],
  823.                                 [
  824.                                     'foo' => '_foo',
  825.                                     'bar' => '_bar',
  826.                                 ],
  827.                                 [
  828.                                     'foo' => [
  829.                                         'storage_key' => '_foo'
  830.                                     ],
  831.                                     'bar' => [
  832.                                         'storage_key' => '_bar'
  833.                                     ]
  834.                                 ]
  835.                             ])
  836.                             ->prototype('array')
  837.                                 ->children()
  838.                                     ->scalarNode('storage_key')
  839.                                         ->defaultNull()
  840.                                     ->end()
  841.                                 ->end()
  842.                             ->end()
  843.                         ->end()
  844.                     ->end()
  845.                 ->end()
  846.             ->end();
  847.     }
  848.     private function addSecurityNode(ArrayNodeDefinition $rootNode)
  849.     {
  850.         $rootNode
  851.             ->children()
  852.                 ->arrayNode('security')
  853.                     ->addDefaultsIfNotSet()
  854.                     ->children()
  855.                         ->arrayNode('encoder_factories')
  856.                             ->info('Encoder factories to use as className => factory service ID mapping')
  857.                             ->example([
  858.                                 'AppBundle\Model\DataObject\User1' => [
  859.                                     'id' => 'website_demo.security.encoder_factory2'
  860.                                 ],
  861.                                 'AppBundle\Model\DataObject\User2' => 'website_demo.security.encoder_factory2'
  862.                             ])
  863.                             ->useAttributeAsKey('class')
  864.                             ->prototype('array')
  865.                             ->beforeNormalization()->ifString()->then(function ($v) {
  866.                                 return ['id' => $v];
  867.                             })->end()
  868.                             ->children()
  869.                                 ->scalarNode('id')->end()
  870.                             ->end()
  871.                         ->end()
  872.                     ->end()
  873.                 ->end()
  874.             ->end()
  875.         ;
  876.     }
  877.     /**
  878.      * Configure exclude paths for web profiler toolbar
  879.      *
  880.      * @param ArrayNodeDefinition $rootNode
  881.      */
  882.     private function addWebProfilerNode(ArrayNodeDefinition $rootNode)
  883.     {
  884.         $webProfilerNode $rootNode->children()
  885.             ->arrayNode('web_profiler')
  886.                 ->example([
  887.                     'toolbar' => [
  888.                         'excluded_routes' => [
  889.                             ['path' => '^/test/path']
  890.                         ]
  891.                     ]
  892.                 ])
  893.                 ->addDefaultsIfNotSet();
  894.         $toolbarNode $webProfilerNode->children()
  895.             ->arrayNode('toolbar')
  896.                 ->addDefaultsIfNotSet();
  897.         $this->addRoutesChild($toolbarNode'excluded_routes');
  898.     }
  899.     /**
  900.      * Add a route prototype child
  901.      *
  902.      * @param ArrayNodeDefinition $parent
  903.      * @param string $name
  904.      */
  905.     private function addRoutesChild(ArrayNodeDefinition $parent$name)
  906.     {
  907.         $node $parent->children()->arrayNode($name);
  908.         /** @var ArrayNodeDefinition|NodeDefinition $prototype */
  909.         $prototype $node->prototype('array');
  910.         $prototype
  911.             ->beforeNormalization()
  912.                 ->ifNull()->then(function () {
  913.                     return [];
  914.                 })
  915.             ->end()
  916.             ->children()
  917.                 ->scalarNode('path')->defaultFalse()->end()
  918.                 ->scalarNode('route')->defaultFalse()->end()
  919.                 ->scalarNode('host')->defaultFalse()->end()
  920.                 ->arrayNode('methods')
  921.                     ->prototype('scalar')->end()
  922.                 ->end()
  923.             ->end();
  924.     }
  925.     /**
  926.      * Add cache config
  927.      *
  928.      * @param ArrayNodeDefinition $rootNode
  929.      */
  930.     private function addCacheNode(ArrayNodeDefinition $rootNode)
  931.     {
  932.         $defaultOptions ConnectionFactory::getDefaultOptions();
  933.         $rootNode->children()
  934.             ->arrayNode('full_page_cache')
  935.                 ->ignoreExtraKeys()
  936.                 ->canBeDisabled()
  937.                 ->addDefaultsIfNotSet()
  938.                 ->children()
  939.                     ->scalarNode('lifetime')
  940.                         ->defaultNull()
  941.                     ->end()
  942.                     ->scalarNode('exclude_patterns')->end()
  943.                     ->scalarNode('exclude_cookie')->end()
  944.                 ->end()
  945.             ->end()
  946.             ->arrayNode('cache')
  947.                 ->ignoreExtraKeys()
  948.                 ->addDefaultsIfNotSet()
  949.                 ->children()
  950.                     ->scalarNode('pool_service_id')
  951.                         ->defaultValue(null)
  952.                     ->end()
  953.                     ->integerNode('default_lifetime')
  954.                         ->defaultValue(2419200// 28 days
  955.                     ->end()
  956.                     ->arrayNode('pools')
  957.                         ->addDefaultsIfNotSet()
  958.                         ->children()
  959.                             ->arrayNode('doctrine')
  960.                                 ->canBeDisabled()
  961.                                 ->children()
  962.                                     ->scalarNode('connection')
  963.                                         ->defaultValue('default')
  964.                                     ->end()
  965.                                 ->end()
  966.                             ->end()
  967.                             ->arrayNode('redis')
  968.                                 ->canBeEnabled()
  969.                                 ->children()
  970.                                     ->arrayNode('connection')
  971.                                         ->info('Redis connection options. See ' ConnectionFactory::class)
  972.                                         ->children()
  973.                                             ->scalarNode('server')->end()
  974.                                             ->integerNode('port')
  975.                                                 ->defaultValue($defaultOptions['port'])
  976.                                             ->end()
  977.                                             ->scalarNode('database')
  978.                                                 ->defaultValue($defaultOptions['database'])
  979.                                             ->end()
  980.                                             ->scalarNode('password')
  981.                                                 ->defaultValue($defaultOptions['password'])
  982.                                             ->end()
  983.                                             ->scalarNode('persistent')
  984.                                                 ->defaultValue($defaultOptions['persistent'])
  985.                                             ->end()
  986.                                             ->booleanNode('force_standalone')
  987.                                                 ->defaultValue($defaultOptions['force_standalone'])
  988.                                             ->end()
  989.                                             ->integerNode('connect_retries')
  990.                                                 ->defaultValue($defaultOptions['connect_retries'])
  991.                                             ->end()
  992.                                             ->floatNode('timeout')
  993.                                                 ->defaultValue($defaultOptions['timeout'])
  994.                                             ->end()
  995.                                             ->floatNode('read_timeout')
  996.                                                 ->defaultValue($defaultOptions['read_timeout'])
  997.                                             ->end()
  998.                                         ->end()
  999.                                     ->end()
  1000.                                     ->arrayNode('options')
  1001.                                         ->info('Redis cache pool options. See ' Redis::class)
  1002.                                         ->children()
  1003.                                             ->booleanNode('notMatchingTags')->end()
  1004.                                             ->integerNode('compress_tags')->end()
  1005.                                             ->integerNode('compress_data')->end()
  1006.                                             ->integerNode('compress_threshold')->end()
  1007.                                             ->scalarNode('compression_lib')->end()
  1008.                                             ->booleanNode('use_lua')->end()
  1009.                                             ->integerNode('lua_max_c_stack')->end()
  1010.                                         ->end()
  1011.                                     ->end()
  1012.                                 ->end()
  1013.                             ->end()
  1014.                         ->end()
  1015.                     ->end()
  1016.                 ->end();
  1017.     }
  1018.     /**
  1019.      * Adds configuration for email source adapters
  1020.      *
  1021.      * @param ArrayNodeDefinition $rootNode
  1022.      */
  1023.     private function addEmailNode(ArrayNodeDefinition $rootNode)
  1024.     {
  1025.         $rootNode
  1026.             ->children()
  1027.                 ->arrayNode('email')
  1028.                 ->addDefaultsIfNotSet()
  1029.                     ->children()
  1030.                         ->arrayNode('sender')
  1031.                             ->children()
  1032.                                 ->scalarNode('name')->end()
  1033.                                 ->scalarNode('email')->end()
  1034.                             ->end()
  1035.                         ->end()
  1036.                         ->arrayNode('return')
  1037.                             ->children()
  1038.                                 ->scalarNode('name')->end()
  1039.                                 ->scalarNode('email')->end()
  1040.                             ->end()
  1041.                         ->end()
  1042.                         ->scalarNode('method')
  1043.                             ->defaultNull()
  1044.                         ->end()
  1045.                         ->arrayNode('debug')
  1046.                             ->children()
  1047.                                 ->scalarNode('email_addresses')
  1048.                                     ->defaultValue('')
  1049.                                 ->end()
  1050.                             ->end()
  1051.                         ->end()
  1052.                         ->scalarNode('usespecific')
  1053.                         ->end()
  1054.                     ->end()
  1055.                 ->end()
  1056.             ->end();
  1057.     }
  1058.     /**
  1059.      * Adds configuration tree for newsletter source adapters
  1060.      *
  1061.      * @param ArrayNodeDefinition $rootNode
  1062.      */
  1063.     private function addNewsletterNode(ArrayNodeDefinition $rootNode)
  1064.     {
  1065.         $rootNode
  1066.             ->children()
  1067.                 ->arrayNode('newsletter')
  1068.                     ->addDefaultsIfNotSet()
  1069.                     ->children()
  1070.                         ->arrayNode('sender')
  1071.                             ->children()
  1072.                                 ->scalarNode('name')->end()
  1073.                                 ->scalarNode('email')->end()
  1074.                             ->end()
  1075.                         ->end()
  1076.                         ->arrayNode('return')
  1077.                             ->children()
  1078.                                 ->scalarNode('name')->end()
  1079.                                 ->scalarNode('email')->end()
  1080.                             ->end()
  1081.                         ->end()
  1082.                         ->scalarNode('method')
  1083.                             ->defaultNull()
  1084.                         ->end()
  1085.                         ->arrayNode('debug')
  1086.                             ->children()
  1087.                                 ->scalarNode('email_addresses')
  1088.                                     ->defaultValue('')
  1089.                                 ->end()
  1090.                             ->end()
  1091.                         ->end()
  1092.                         ->booleanNode('use_specific')
  1093.                             ->beforeNormalization()
  1094.                                 ->ifString()
  1095.                                 ->then(function ($v) {
  1096.                                     return (bool)$v;
  1097.                                 })
  1098.                             ->end()
  1099.                         ->end()
  1100.                         ->arrayNode('source_adapters')
  1101.                             ->useAttributeAsKey('name')
  1102.                                 ->prototype('scalar')
  1103.                             ->end()
  1104.                         ->end()
  1105.                     ->end()
  1106.                 ->end()
  1107.             ->end();
  1108.     }
  1109.     /**
  1110.      * Adds configuration tree for custom report adapters
  1111.      *
  1112.      * @param ArrayNodeDefinition $rootNode
  1113.      */
  1114.     private function addCustomReportsNode(ArrayNodeDefinition $rootNode)
  1115.     {
  1116.         $rootNode
  1117.             ->children()
  1118.                 ->arrayNode('custom_report')
  1119.                     ->addDefaultsIfNotSet()
  1120.                     ->children()
  1121.                         ->arrayNode('adapters')
  1122.                             ->useAttributeAsKey('name')
  1123.                                 ->prototype('scalar')
  1124.                             ->end()
  1125.                         ->end()
  1126.                     ->end()
  1127.                 ->end()
  1128.             ->end();
  1129.     }
  1130.     /**
  1131.      * Adds configuration tree node for migrations
  1132.      *
  1133.      * @param ArrayNodeDefinition $rootNode
  1134.      */
  1135.     private function addMigrationsNode(ArrayNodeDefinition $rootNode)
  1136.     {
  1137.         $rootNode
  1138.             ->children()
  1139.                 ->arrayNode('migrations')
  1140.                     ->addDefaultsIfNotSet()
  1141.                     ->children()
  1142.                         ->arrayNode('sets')
  1143.                             ->useAttributeAsKey('identifier')
  1144.                             ->defaultValue([])
  1145.                             ->info('Migration sets which can be used apart from bundle migrations. Use the -s option in migration commands to select a specific set.')
  1146.                             ->example([
  1147.                                 [
  1148.                                     'custom_set' => [
  1149.                                         'name' => 'Custom Migrations',
  1150.                                         'namespace' => 'App\\Migrations\\Custom',
  1151.                                         'directory' => 'src/App/Migrations/Custom'
  1152.                                     ],
  1153.                                     'custom_set_2' => [
  1154.                                         'name' => 'Custom Migrations 2',
  1155.                                         'namespace' => 'App\\Migrations\\Custom2',
  1156.                                         'directory' => 'src/App/Migrations/Custom2',
  1157.                                         'connection' => 'custom_connection'
  1158.                                     ],
  1159.                                 ]
  1160.                             ])
  1161.                             ->prototype('array')
  1162.                                 ->children()
  1163.                                     ->scalarNode('identifier')->end()
  1164.                                     ->scalarNode('name')
  1165.                                         ->isRequired()
  1166.                                         ->cannotBeEmpty()
  1167.                                     ->end()
  1168.                                     ->scalarNode('namespace')
  1169.                                         ->isRequired()
  1170.                                         ->cannotBeEmpty()
  1171.                                     ->end()
  1172.                                     ->scalarNode('directory')
  1173.                                         ->isRequired()
  1174.                                         ->cannotBeEmpty()
  1175.                                     ->end()
  1176.                                     ->scalarNode('connection')
  1177.                                         ->info('If defined, the DBAL connection defined here will be used')
  1178.                                         ->defaultNull()
  1179.                                         ->beforeNormalization()
  1180.                                             ->ifTrue(function ($v) {
  1181.                                                 return empty(trim($v));
  1182.                                             })
  1183.                                             ->then(function () {
  1184.                                                 return null;
  1185.                                             })
  1186.                                         ->end()
  1187.                                     ->end()
  1188.                                 ->end()
  1189.                             ->end()
  1190.                         ->end()
  1191.                     ->end()
  1192.                 ->end()
  1193.             ->end();
  1194.     }
  1195.     private function addTargetingNode(ArrayNodeDefinition $rootNode)
  1196.     {
  1197.         $rootNode
  1198.             ->children()
  1199.                 ->arrayNode('targeting')
  1200.                     ->canBeDisabled()
  1201.                     ->addDefaultsIfNotSet()
  1202.                     ->children()
  1203.                         ->scalarNode('storage_id')
  1204.                             ->info('Service ID of the targeting storage which should be used. This ID will be aliased to ' TargetingStorageInterface::class)
  1205.                             ->defaultValue(CookieStorage::class)
  1206.                             ->cannotBeEmpty()
  1207.                         ->end()
  1208.                         ->arrayNode('session')
  1209.                             ->info('Enables HTTP session support by configuring session bags and the full page cache')
  1210.                             ->canBeEnabled()
  1211.                         ->end()
  1212.                         ->arrayNode('data_providers')
  1213.                             ->useAttributeAsKey('key')
  1214.                                 ->prototype('scalar')
  1215.                             ->end()
  1216.                         ->end()
  1217.                         ->arrayNode('conditions')
  1218.                             ->useAttributeAsKey('key')
  1219.                                 ->prototype('scalar')
  1220.                             ->end()
  1221.                         ->end()
  1222.                         ->arrayNode('action_handlers')
  1223.                             ->useAttributeAsKey('name')
  1224.                                 ->prototype('scalar')
  1225.                             ->end()
  1226.                         ->end()
  1227.                     ->end()
  1228.                 ->end()
  1229.             ->end();
  1230.     }
  1231.     private function addSitemapsNode(ArrayNodeDefinition $rootNode)
  1232.     {
  1233.         $rootNode
  1234.             ->children()
  1235.                 ->arrayNode('sitemaps')
  1236.                     ->addDefaultsIfNotSet()
  1237.                     ->children()
  1238.                         ->arrayNode('generators')
  1239.                             ->useAttributeAsKey('name')
  1240.                             ->prototype('array')
  1241.                                 ->beforeNormalization()
  1242.                                     ->ifString()
  1243.                                     ->then(function ($v) {
  1244.                                         return [
  1245.                                             'enabled' => true,
  1246.                                             'generator_id' => $v,
  1247.                                             'priority' => 0
  1248.                                         ];
  1249.                                     })
  1250.                                 ->end()
  1251.                                 ->addDefaultsIfNotSet()
  1252.                                 ->canBeDisabled()
  1253.                                 ->children()
  1254.                                     ->scalarNode('generator_id')
  1255.                                         ->cannotBeEmpty()
  1256.                                     ->end()
  1257.                                     ->integerNode('priority')
  1258.                                         ->defaultValue(0)
  1259.                                     ->end()
  1260.                                 ->end()
  1261.                             ->end()
  1262.                         ->end()
  1263.                     ->end()
  1264.                 ->end()
  1265.             ->end()
  1266.         ->end();
  1267.     }
  1268.     private function addMimeNode(ArrayNodeDefinition $rootNode)
  1269.     {
  1270.         $rootNode
  1271.             ->children()
  1272.                 ->arrayNode('mime')
  1273.                     ->addDefaultsIfNotSet()
  1274.                     ->children()
  1275.                         ->arrayNode('extensions')
  1276.                             ->useAttributeAsKey('name')
  1277.                             ->prototype('scalar')
  1278.                         ->end()
  1279.                     ->end()
  1280.                 ->end()
  1281.             ->end()
  1282.         ->end();
  1283.     }
  1284.     private function addWorkflowNode(ArrayNodeDefinition $rootNode)
  1285.     {
  1286.         $rootNode
  1287.             ->children()
  1288.                  ->arrayNode('workflows')
  1289.                         ->useAttributeAsKey('name')
  1290.                         ->prototype('array')
  1291.                             ->children()
  1292.                                 ->arrayNode('placeholders')
  1293.                                     ->info('Placeholder values in this workflow configuration (locale: "%%locale%%") will be replaced by the given placeholder value (eg. "de_AT")')
  1294.                                     ->example([
  1295.                                         'placeholders' => [
  1296.                                             '%%locale%%' => 'de_AT'
  1297.                                         ]
  1298.                                     ])
  1299.                                     ->defaultValue([])
  1300.                                     ->beforeNormalization()
  1301.                                         ->castToArray()
  1302.                                         ->always()
  1303.                                         ->then(function ($placeholders) {
  1304.                                             $this->placeholders $placeholders;
  1305.                                             return $placeholders;
  1306.                                         })
  1307.                                     ->end()
  1308.                                     ->prototype('scalar')->end()
  1309.                                 ->end()
  1310.                                 ->booleanNode('enabled')
  1311.                                     ->defaultTrue()
  1312.                                     ->info('Can be used to enable or disable the workflow.')
  1313.                                 ->end()
  1314.                                 ->integerNode('priority')
  1315.                                     ->defaultValue(0)
  1316.                                     ->info('When multiple custom view or permission settings from different places in different workflows are valid, the workflow with the highest priority will be used.')
  1317.                                 ->end()
  1318.                                 ->scalarNode('label')
  1319.                                     ->info('Will be used in the backend interface as nice name for the workflow. If not set the technical workflow name will be used as label too.')
  1320.                                 ->end()
  1321.                                 ->arrayNode('audit_trail')
  1322.                                     ->canBeEnabled()
  1323.                                     ->info('Enable default audit trail feature provided by Symfony. Take a look at the Symfony docs for more details.')
  1324.                                 ->end()
  1325.                                 ->enumNode('type')
  1326.                                     ->values(['workflow''state_machine'])
  1327.                                     ->info('A workflow with type "workflow" can handle multiple places at one time whereas a state_machine provides a finite state_machine (only one place at one time). Take a look at the Symfony docs for more details.')
  1328.                                 ->end()
  1329.                                 ->arrayNode('marking_store')
  1330.                                     ->fixXmlConfig('argument')
  1331.                                     ->children()
  1332.                                         ->enumNode('type')
  1333.                                             ->values(['multiple_state''single_state''state_table''data_object_multiple_state''data_object_splitted_state'])
  1334.                                         ->end()
  1335.                                         ->arrayNode('arguments')
  1336.                                             ->beforeNormalization()
  1337.                                                 ->always()
  1338.                                                 ->then(function ($arguments) {
  1339.                                                     if (is_string($arguments)) {
  1340.                                                         $arguments = [$arguments];
  1341.                                                     }
  1342.                                                     if (!empty($this->placeholders)) {
  1343.                                                         $arguments $this->placeholderProcessor->mergePlaceholders($arguments$this->placeholders);
  1344.                                                     }
  1345.                                                     return $arguments;
  1346.                                                 })
  1347.                                             ->end()
  1348.                                             ->requiresAtLeastOneElement()
  1349.                                             ->prototype('variable')
  1350.                                             ->end()
  1351.                                         ->end()
  1352.                                         ->scalarNode('service')
  1353.                                             ->cannotBeEmpty()
  1354.                                         ->end()
  1355.                                     ->end()
  1356.                                     ->info('Handles the way how the state/place is stored. If not defined "state_table" will be used as default. Take a look at @TODO for a description of the different types.')
  1357.                                     ->validate()
  1358.                                         ->ifTrue(function ($v) {
  1359.                                             return isset($v['type']) && isset($v['service']);
  1360.                                         })
  1361.                                         ->thenInvalid('"type" and "service" cannot be used together.')
  1362.                                     ->end()
  1363.                                     ->validate()
  1364.                                         ->ifTrue(function ($v) {
  1365.                                             return !empty($v['arguments']) && isset($v['service']);
  1366.                                         })
  1367.                                         ->thenInvalid('"arguments" and "service" cannot be used together.')
  1368.                                     ->end()
  1369.                                 ->end()
  1370.                                 ->arrayNode('supports')
  1371.                                     ->beforeNormalization()
  1372.                                         ->ifString()
  1373.                                         ->then(function ($v) {
  1374.                                             return [$v];
  1375.                                         })
  1376.                                     ->end()
  1377.                                     ->prototype('scalar')
  1378.                                         ->cannotBeEmpty()
  1379.                                     ->end()
  1380.                                     ->info('List of supported entity classes. Take a look at the Symfony docs for more details.')
  1381.                                     ->example(['\Pimcore\Model\DataObject\Product'])
  1382.                                 ->end()
  1383.                                 ->arrayNode('support_strategy')
  1384.                                     ->fixXmlConfig('argument')
  1385.                                     ->children()
  1386.                                         ->enumNode('type')
  1387.                                             ->values(['expression'])
  1388.                                             ->info('Type "expression": a symfony expression to define a criteria.')
  1389.                                         ->end()
  1390.                                         ->arrayNode('arguments')
  1391.                                             ->beforeNormalization()
  1392.                                                 ->ifString()
  1393.                                                 ->then(function ($v) {
  1394.                                                     return [$v];
  1395.                                                 })
  1396.                                             ->end()
  1397.                                             ->requiresAtLeastOneElement()
  1398.                                             ->prototype('variable')
  1399.                                             ->end()
  1400.                                         ->end()
  1401.                                         ->scalarNode('service')
  1402.                                             ->cannotBeEmpty()
  1403.                                             ->info('Define a custom service to handle the logic. Take a look at the Symfony docs for more details.')
  1404.                                         ->end()
  1405.                                     ->end()
  1406.                                     ->validate()
  1407.                                         ->ifTrue(function ($v) {
  1408.                                             return isset($v['type']) && isset($v['service']);
  1409.                                         })
  1410.                                         ->thenInvalid('"type" and "service" cannot be used together.')
  1411.                                     ->end()
  1412.                                     ->validate()
  1413.                                         ->ifTrue(function ($v) {
  1414.                                             return !empty($v['arguments']) && isset($v['service']);
  1415.                                         })
  1416.                                         ->thenInvalid('"arguments" and "service" cannot be used together.')
  1417.                                     ->end()
  1418.                                     ->info('Can be used to implement a special logic which subjects are supported by the workflow. For example only products matching certain criteria.')
  1419.                                     ->example([
  1420.                                         'type' => 'expression',
  1421.                                         'arguments' => [
  1422.                                             '\Pimcore\Model\DataObject\Product',
  1423.                                             'subject.getProductType() == "article" and is_fully_authenticated() and "ROLE_PIMCORE_ADMIN" in roles'
  1424.                                         ]
  1425.                                     ])
  1426.                                 ->end()
  1427.                                 ->scalarNode('initial_place')
  1428.                                     ->defaultNull()
  1429.                                     ->setDeprecated('The "%node%" option is deprecated. Use "initial_markings" instead.')
  1430.                                     ->info('Will be applied when the current place is empty.')
  1431.                                 ->end()
  1432.                                 ->arrayNode('initial_markings')
  1433.                                     ->info('Can be used to set the initial places (markings) for a workflow. Note that this option is Symfony 4.3+ only')
  1434.                                     ->beforeNormalization()
  1435.                                         ->ifString()
  1436.                                             ->then(function ($v) {
  1437.                                                 return [$v];
  1438.                                             })
  1439.                                         ->end()
  1440.                                         ->requiresAtLeastOneElement()
  1441.                                         ->prototype('scalar')
  1442.                                         ->cannotBeEmpty()
  1443.                                     ->end()
  1444.                                 ->end()
  1445.                                 ->arrayNode('places')
  1446.                                     ->prototype('array')
  1447.                                         ->children()
  1448.                                             ->scalarNode('label')->info('Nice name which will be used in the Pimcore backend.')->end()
  1449.                                             ->scalarNode('title')->info('Title/tooltip for this place when it is displayed in the header of the Pimcore element detail view in the backend.')->defaultValue('')->end()
  1450.                                             ->scalarNode('color')->info('Color of the place which will be used in the Pimcore backend.')->defaultValue('#bfdadc')->end()
  1451.                                             ->booleanNode('colorInverted')->info('If set to true the color will be used as border and font color otherwise as background color.')->defaultFalse()->end()
  1452.                                             ->booleanNode('visibleInHeader')->info('If set to false, the place will be hidden in the header of the Pimcore element detail view in the backend.')->defaultTrue()->end()
  1453.                                             ->arrayNode('permissions')
  1454.                                                 ->prototype('array')
  1455.                                                     ->children()
  1456.                                                         ->scalarNode('condition')->info('A symfony expression can be configured here. The first set of permissions which are matching the condition will be used.')->end()
  1457.                                                         ->booleanNode('save')->info('save permission as it can be configured in Pimcore workplaces')->end()
  1458.                                                         ->booleanNode('publish')->info('publish permission as it can be configured in Pimcore workplaces')->end()
  1459.                                                         ->booleanNode('unpublish')->info('unpublish permission as it can be configured in Pimcore workplaces')->end()
  1460.                                                         ->booleanNode('delete')->info('delete permission as it can be configured in Pimcore workplaces')->end()
  1461.                                                         ->booleanNode('rename')->info('rename permission as it can be configured in Pimcore workplaces')->end()
  1462.                                                         ->booleanNode('view')->info('view permission as it can be configured in Pimcore workplaces')->end()
  1463.                                                         ->booleanNode('settings')->info('settings permission as it can be configured in Pimcore workplaces')->end()
  1464.                                                         ->booleanNode('versions')->info('versions permission as it can be configured in Pimcore workplaces')->end()
  1465.                                                         ->booleanNode('properties')->info('properties permission as it can be configured in Pimcore workplaces')->end()
  1466.                                                         ->booleanNode('modify')->info('a short hand for save, publish, unpublish, delete + rename')->end()
  1467.                                                         ->scalarNode('objectLayout')->info('if set, the user will see the configured custom data object layout')->end()
  1468.                                                     ->end()
  1469.                                                 ->end()
  1470.                                             ->end()
  1471.                                         ->end()
  1472.                                     ->end()
  1473.                                     ->beforeNormalization()
  1474.                                         ->always()
  1475.                                         ->then(function ($places) {
  1476.                                             if (!empty($this->placeholders)) {
  1477.                                                 foreach ($places as $name => $place) {
  1478.                                                     $places[$name] = $this->placeholderProcessor->mergePlaceholders($place$this->placeholders);
  1479.                                                 }
  1480.                                             }
  1481.                                             return $places;
  1482.                                         })
  1483.                                     ->end()
  1484.                                     ->example([
  1485.                                         'places' => [
  1486.                                             'closed' => [
  1487.                                                 'label' => 'close product',
  1488.                                                 'permissions' => [
  1489.                                                     [
  1490.                                                         'condition' => "is_fully_authenticated() and 'ROLE_PIMCORE_ADMIN' in roles",
  1491.                                                         'modify' => false
  1492.                                                     ],
  1493.                                                     [
  1494.                                                         'modify' => false,
  1495.                                                         'objectLayout' => 2
  1496.                                                     ]
  1497.                                                 ]
  1498.                                             ]
  1499.                                         ]
  1500.                                     ])
  1501.                                 ->end()
  1502.                                 ->arrayNode('transitions')
  1503.                                     ->beforeNormalization()
  1504.                                         ->always()
  1505.                                         ->then(function ($transitions) {
  1506.                                             // It's an indexed array, we let the validation occurs
  1507.                                             if (isset($transitions[0])) {
  1508.                                                 return $transitions;
  1509.                                             }
  1510.                                             foreach ($transitions as $name => $transition) {
  1511.                                                 if (array_key_exists('name', (array) $transition)) {
  1512.                                                     continue;
  1513.                                                 }
  1514.                                                 $transition['name'] = $name;
  1515.                                                 $transitions[$name] = $transition;
  1516.                                             }
  1517.                                             return $transitions;
  1518.                                         })
  1519.                                     ->end()
  1520.                                     ->isRequired()
  1521.                                     ->requiresAtLeastOneElement()
  1522.                                     ->prototype('array')
  1523.                                         ->children()
  1524.                                             ->scalarNode('name')
  1525.                                                 ->isRequired()
  1526.                                                 ->cannotBeEmpty()
  1527.                                             ->end()
  1528.                                             ->scalarNode('guard')
  1529.                                                 ->cannotBeEmpty()
  1530.                                                 ->info('An expression to block the transition')
  1531.                                                 ->example('is_fully_authenticated() and has_role(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
  1532.                                             ->end()
  1533.                                             ->arrayNode('from')
  1534.                                                 ->beforeNormalization()
  1535.                                                     ->ifString()
  1536.                                                     ->then(function ($v) {
  1537.                                                         return [$v];
  1538.                                                     })
  1539.                                                 ->end()
  1540.                                                 ->requiresAtLeastOneElement()
  1541.                                                 ->prototype('scalar')
  1542.                                                     ->cannotBeEmpty()
  1543.                                                 ->end()
  1544.                                             ->end()
  1545.                                             ->arrayNode('to')
  1546.                                                 ->beforeNormalization()
  1547.                                                     ->ifString()
  1548.                                                     ->then(function ($v) {
  1549.                                                         return [$v];
  1550.                                                     })
  1551.                                                 ->end()
  1552.                                                 ->requiresAtLeastOneElement()
  1553.                                                 ->prototype('scalar')
  1554.                                                     ->cannotBeEmpty()
  1555.                                                 ->end()
  1556.                                             ->end()
  1557.                                             ->arrayNode('options')
  1558.                                                 ->children()
  1559.                                                     ->scalarNode('label')->info('Nice name for the Pimcore backend.')->end()
  1560.                                                     ->arrayNode('notes')
  1561.                                                         ->children()
  1562.                                                             ->booleanNode('commentEnabled')->defaultFalse()->info('If enabled a detail window will open when the user executes the transition. In this detail view the user be asked to enter a "comment". This comment then will be used as comment for the notes/events feature.')->end()
  1563.                                                             ->booleanNode('commentRequired')->defaultFalse()->info('Set this to true if the comment should be a required field.')->end()
  1564.                                                             ->scalarNode('commentSetterFn')->info('Can be used for data objects. The comment will be saved to the data object additionally to the notes/events through this setter function.')->end()
  1565.                                                             ->scalarNode('commentGetterFn')->info('Can be used for data objects to prefill the comment field with data from the data object.')->end()
  1566.                                                             ->scalarNode('type')->defaultValue('Status update')->info('Set\'s the type string in the saved note.')->end()
  1567.                                                             ->scalarNode('title')->info('An optional alternative "title" for the note, if blank the actions transition result is used.')->end()
  1568.                                                             ->arrayNode('additionalFields')
  1569.                                                                 ->prototype('array')
  1570.                                                                     ->children()
  1571.                                                                         ->scalarNode('name')->isRequired()->info('The technical name used in the input form.')->end()
  1572.                                                                         ->enumNode('fieldType')
  1573.                                                                             ->isRequired()
  1574.                                                                             ->values(['input''textarea''select''datetime''date''user''checkbox'])
  1575.                                                                             ->info('The data component name/field type.')
  1576.                                                                         ->end()
  1577.                                                                         ->scalarNode('title')->info('The label used by the field')->end()
  1578.                                                                         ->booleanNode('required')->defaultFalse()->info('Whether or not the field is required.')->end()
  1579.                                                                         ->scalarNode('setterFn')->info('Optional setter function (available in the element, for example in the updated object), if not specified, data will be added to notes. The Workflow manager will call the function with the whole field data.')->end()
  1580.                                                                         ->arrayNode('fieldTypeSettings')
  1581.                                                                              ->prototype('variable')->end()
  1582.                                                                              ->info('Will be passed to the underlying Pimcore data object field type. Can be used to configure the options of a select box for example.')
  1583.                                                                         ->end()
  1584.                                                                     ->end()
  1585.                                                                 ->end()
  1586.                                                                 ->info('Add additional field to the transition detail window.')
  1587.                                                             ->end()
  1588.                                                         ->end()
  1589.                                                     ->end()
  1590.                                                     ->scalarNode('iconClass')->info('Css class to define the icon which will be used in the actions button in the backend.')->end()
  1591.                                                     ->scalarNode('objectLayout')->defaultValue(false)->info('Forces an object layout after the transition was performed. This objectLayout setting overrules all objectLayout settings within the places configs.')->end()
  1592.                                                     ->arrayNode('notificationSettings')
  1593.                                                         ->prototype('array')
  1594.                                                             ->children()
  1595.                                                                 ->scalarNode('condition')->info('A symfony expression can be configured here. All sets of notification which are matching the condition will be used.')->end()
  1596.                                                                 ->arrayNode('notifyUsers')
  1597.                                                                     ->prototype('scalar')
  1598.                                                                         ->cannotBeEmpty()
  1599.                                                                     ->end()
  1600.                                                                     ->info('Send an email notification to a list of users (user names) when the transition get\'s applied')
  1601.                                                                 ->end()
  1602.                                                                 ->arrayNode('notifyRoles')
  1603.                                                                     ->prototype('scalar')
  1604.                                                                         ->cannotBeEmpty()
  1605.                                                                     ->end()
  1606.                                                                     ->info('Send an email notification to a list of user roles (role names) when the transition get\'s applied')
  1607.                                                                 ->end()
  1608.                                                                 ->arrayNode('channelType')
  1609.                                                                     ->requiresAtLeastOneElement()
  1610.                                                                     ->enumPrototype()
  1611.                                                                         ->values([NotificationSubscriber::NOTIFICATION_CHANNEL_MAILNotificationSubscriber::NOTIFICATION_CHANNEL_PIMCORE_NOTIFICATION])
  1612.                                                                         ->cannotBeEmpty()
  1613.                                                                         ->defaultValue(NotificationSubscriber::NOTIFICATION_CHANNEL_MAIL)
  1614.                                                                     ->end()
  1615.                                                                     ->info('Define which channel notification should be sent to, possible values "' NotificationSubscriber::NOTIFICATION_CHANNEL_MAIL '" and "' NotificationSubscriber::NOTIFICATION_CHANNEL_PIMCORE_NOTIFICATION '", default value is "' NotificationSubscriber::NOTIFICATION_CHANNEL_MAIL '".')
  1616.                                                                     ->addDefaultChildrenIfNoneSet()
  1617.                                                                 ->end()
  1618.                                                                 ->enumNode('mailType')
  1619.                                                                     ->values([NotificationSubscriber::MAIL_TYPE_TEMPLATENotificationSubscriber::MAIL_TYPE_DOCUMENT])
  1620.                                                                     ->defaultValue(NotificationSubscriber::MAIL_TYPE_TEMPLATE)
  1621.                                                                     ->info('Type of mail source.')
  1622.                                                                 ->end()
  1623.                                                                 ->scalarNode('mailPath')
  1624.                                                                     ->defaultValue(NotificationSubscriber::DEFAULT_MAIL_TEMPLATE_PATH)
  1625.                                                                     ->info('Path to mail source - either Symfony path to template or fullpath to Pimcore document. Optional use ' NotificationEmailService::MAIL_PATH_LANGUAGE_PLACEHOLDER ' as placeholder for language.')
  1626.                                                                 ->end()
  1627.                                                             ->end()
  1628.                                                         ->end()
  1629.                                                     ->end()
  1630.                                                     ->enumNode('changePublishedState')
  1631.                                                         ->values([ChangePublishedStateSubscriber::NO_CHANGEChangePublishedStateSubscriber::FORCE_UNPUBLISHEDChangePublishedStateSubscriber::FORCE_PUBLISHEDChangePublishedStateSubscriber::SAVE_VERSION])
  1632.                                                         ->defaultValue(ChangePublishedStateSubscriber::NO_CHANGE)
  1633.                                                         ->info('Change published state of element while transition (only available for documents and data objects).')
  1634.                                                     ->end()
  1635.                                                 ->end()
  1636.                                             ->end()
  1637.                                         ->end()
  1638.                                     ->end()
  1639.                                     ->example([
  1640.                                         'close_product' => [
  1641.                                             'from' => 'open',
  1642.                                             'to' => 'closed',
  1643.                                             'options' => [
  1644.                                                 'label' => 'close product',
  1645.                                                 'notes' => [
  1646.                                                     'commentEnabled' => true,
  1647.                                                     'commentRequired' => true,
  1648.                                                     'additionalFields' => [
  1649.                                                         [
  1650.                                                             'name' => 'accept',
  1651.                                                             'title' => 'accept terms',
  1652.                                                             'required' => true,
  1653.                                                             'fieldType' => 'checkbox',
  1654.                                                         ],
  1655.                                                         [
  1656.                                                             'name' => 'select',
  1657.                                                             'title' => 'please select a type',
  1658.                                                             'setterFn' => 'setSpecialWorkflowType',
  1659.                                                             'fieldType' => 'select',
  1660.                                                             'fieldTypeSettings' => [
  1661.                                                                 'options' => [
  1662.                                                                     ['key' => 'Option A''value' => 'a'],
  1663.                                                                     ['key' => 'Option B''value' => 'b'],
  1664.                                                                     ['key' => 'Option C''value' => 'c'],
  1665.                                                                 ]
  1666.                                                             ],
  1667.                                                         ]
  1668.                                                     ],
  1669.                                                 ]
  1670.                                             ]
  1671.                                         ]
  1672.                                     ])
  1673.                                 ->end()
  1674.                                 ->arrayNode('globalActions')
  1675.                                     ->prototype('array')
  1676.                                         ->children()
  1677.                                             ->scalarNode('label')->info('Nice name for the Pimcore backend.')->end()
  1678.                                             ->scalarNode('iconClass')->info('Css class to define the icon which will be used in the actions button in the backend.')->end()
  1679.                                             ->scalarNode('objectLayout')->defaultValue(false)->info('Forces an object layout after the global action was performed. This objectLayout setting overrules all objectLayout settings within the places configs.')->end()
  1680.                                             ->scalarNode('guard')
  1681.                                                 ->cannotBeEmpty()
  1682.                                                 ->info('An expression to block the action')
  1683.                                                 ->example('is_fully_authenticated() and has_role(\'ROLE_JOURNALIST\') and subject.getTitle() == \'My first article\'')
  1684.                                             ->end()
  1685.                                             ->arrayNode('to')
  1686.                                                 ->beforeNormalization()
  1687.                                                     ->ifString()
  1688.                                                     ->then(function ($v) {
  1689.                                                         return [$v];
  1690.                                                     })
  1691.                                                 ->end()
  1692.                                                 ->requiresAtLeastOneElement()
  1693.                                                 ->prototype('scalar')
  1694.                                                     ->cannotBeEmpty()
  1695.                                                 ->end()
  1696.                                                 ->info('Optionally set the current place of the workflow. Can be used for example to reset the workflow to the initial place.')
  1697.                                             ->end()
  1698.                                             ->arrayNode('notes')
  1699.                                                 ->children()
  1700.                                                     ->booleanNode('commentEnabled')->defaultFalse()->end()
  1701.                                                     ->booleanNode('commentRequired')->defaultFalse()->end()
  1702.                                                     ->scalarNode('commentSetterFn')->end()
  1703.                                                     ->scalarNode('commentGetterFn')->end()
  1704.                                                     ->scalarNode('type')->defaultValue('Status update')->end()
  1705.                                                     ->scalarNode('title')->end()
  1706.                                                     ->arrayNode('additionalFields')
  1707.                                                         ->prototype('array')
  1708.                                                             ->children()
  1709.                                                                 ->scalarNode('name')->isRequired()->end()
  1710.                                                                 ->enumNode('fieldType')
  1711.                                                                     ->isRequired()
  1712.                                                                     ->values(['input''textarea''select''datetime''date''user''checkbox'])
  1713.                                                                 ->end()
  1714.                                                                 ->scalarNode('title')->end()
  1715.                                                                 ->booleanNode('required')->defaultFalse()->end()
  1716.                                                                 ->scalarNode('setterFn')->end()
  1717.                                                                 ->arrayNode('fieldTypeSettings')
  1718.                                                                      ->prototype('variable')->end()
  1719.                                                                 ->end()
  1720.                                                             ->end()
  1721.                                                         ->end()
  1722.                                                     ->end()
  1723.                                                 ->end()
  1724.                                                 ->info('See notes section of transitions. It works exactly the same way.')
  1725.                                             ->end()
  1726.                                         ->end()
  1727.                                     ->end()
  1728.                                     ->info('Actions which will be added to actions button independently of the current workflow place.')
  1729.                                 ->end()
  1730.                             ->end()
  1731.                             ->validate()
  1732.                                 ->ifTrue(function ($v) {
  1733.                                     return $v['supports'] && isset($v['support_strategy']);
  1734.                                 })
  1735.                                 ->thenInvalid('"supports" and "support_strategy" cannot be used together.')
  1736.                             ->end()
  1737.                             ->validate()
  1738.                                 ->ifTrue(function ($v) {
  1739.                                     return !$v['supports'] && !isset($v['support_strategy']);
  1740.                                 })
  1741.                                 ->thenInvalid('"supports" or "support_strategy" should be configured.')
  1742.                             ->end()
  1743.                         ->end()
  1744.                     ->end()
  1745.                 ->end()
  1746.                 ->addDefaultsIfNotSet()
  1747.             ->end();
  1748.     }
  1749. }