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

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