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

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