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