src/Pimcore/Bundle/DamBundle/DependencyInjection/Configuration.php line 359

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore DAM
  4.  *
  5.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  6.  */
  7. namespace Pimcore\Bundle\DamBundle\DependencyInjection;
  8. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  9. use Symfony\Component\Config\Definition\ConfigurationInterface;
  10. /**
  11.  * This is the class that validates and merges configuration from your app/config files.
  12.  *
  13.  * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
  14.  */
  15. class Configuration implements ConfigurationInterface
  16. {
  17.     /**
  18.      * {@inheritdoc}
  19.      */
  20.     public function getConfigTreeBuilder()
  21.     {
  22.         $treeBuilder = new TreeBuilder();
  23.         $rootNode $treeBuilder->root('pimcore_dam');
  24.         $rootNode->addDefaultsIfNotSet();
  25.         $rootNode->append($this->buildFrontendNode());
  26.         $rootNode->append($this->buildBackendNode());
  27.         $rootNode->append($this->buildFiltersNode());
  28.         $rootNode->append($this->buildExtensionNode());
  29.         $rootNode->append($this->buildDownloadNode());
  30.         $rootNode->append($this->buildAssetNode());
  31.         return $treeBuilder;
  32.     }
  33.     /**
  34.      * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
  35.      */
  36.     private function buildFrontendNode()
  37.     {
  38.         $treeBuilder = new TreeBuilder();
  39.         $frontend $treeBuilder->root('frontend');
  40.         $frontend
  41.             ->addDefaultsIfNotSet()
  42.             ->info('Settings for Share Frontend via Token Access');
  43.         $frontend
  44.             ->children()
  45.                 ->arrayNode('customize')
  46.                     ->info('Options to customize Share frontend')
  47.                     ->children()
  48.                         ->variableNode('css')
  49.                             ->info('Paths to custom CSS files to be injected into DAM frontend, e.g. [/static/css/custom.css, ...]')
  50.                             ->validate()
  51.                                 ->ifTrue(function ($v) {
  52.                                     return $v !== null && false === is_string($v) && false === is_array($v);
  53.                                 })
  54.                                 ->thenInvalid('it must either be of type null, a string or an array')
  55.                             ->end()
  56.                         ->end()
  57.                         ->variableNode('js')
  58.                             ->info('Paths to custom JS files to be injected into DAM frontend, e.g. [/static/js/custom.js, ...]')
  59.                             ->validate()
  60.                                 ->ifTrue(function ($v) {
  61.                                     return $v !== null && false === is_string($v) && false === is_array($v);
  62.                                 })
  63.                                 ->thenInvalid('it must either be of type null, a string or an array')
  64.                             ->end()
  65.                         ->end()
  66.                         ->scalarNode('shareUrl')->info('Optional set special share URL to not use the main domain. Needs to be configured at webserver also.')->end()
  67.                     ->end()
  68.                 ->end()
  69.             ->end()
  70.         ;
  71.         return $frontend;
  72.     }
  73.     private function buildAssetNode() {
  74.         $treeBuilder = new TreeBuilder();
  75.         $assets $treeBuilder->root('assets');
  76.         $assets->addDefaultsIfNotSet('Custom Configure Item Classes');
  77.         $assets->children()
  78.             ->arrayNode('classes')
  79.             ->prototype('scalar')
  80.             ->end();
  81.         return $assets;
  82.     }
  83.     /**
  84.      * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
  85.      */
  86.     private function buildBackendNode()
  87.     {
  88.         $treeBuilder = new TreeBuilder();
  89.         $backend $treeBuilder->root('backend');
  90.         $backend
  91.             ->addDefaultsIfNotSet()
  92.                 ->info('Settings for DAM Frontend via Pimcore user access');
  93.         $backend
  94.             ->children()
  95.                 ->arrayNode('languageMapping')
  96.                     ->info('Optionally map language set in Pimcore user to language available in shared translations.')
  97.                     ->prototype('scalar')->end()
  98.                     ->example(['en_GB' => 'en'])
  99.                     ->defaultValue([])
  100.                 ->end()
  101.                 ->arrayNode('ui')
  102.                     ->info('General Settings for User Interface')
  103.                     ->addDefaultsIfNotSet()
  104.                     ->children()
  105.                         ->arrayNode('listview')
  106.                             ->info('Settings for list view')
  107.                             ->addDefaultsIfNotSet()
  108.                             ->children()
  109.                                 ->arrayNode('listview_metadata')
  110.                                     ->info('Configure metadata fields to be shown in list view')
  111.                                     ->prototype('scalar')->defaultValue([])->end()
  112.                                 ->end()
  113.                                 ->arrayNode('sort')
  114.                                     ->info('Configure sorting options')
  115.                                     ->prototype('array')
  116.                                         ->children()
  117.                                             ->scalarNode('iconClass')
  118.                                                 ->info('Icon for button')
  119.                                                 ->example('glyphicon-font')
  120.                                             ->end()
  121.                                             ->scalarNode('criteria')
  122.                                                 ->info('Fieldname to sort after')
  123.                                                 ->example('filename')
  124.                                             ->end()
  125.                                             ->booleanNode('default')
  126.                                                 ->info('Should it be default sorting')
  127.                                                 ->defaultFalse()
  128.                                             ->end()
  129.                                         ->end()
  130.                                     ->end()
  131.                                 ->end()
  132.                             ->end()
  133.                         ->end()
  134.                         ->arrayNode('sidebar')
  135.                             ->info('Settings for sidebar of DAM Frontend')
  136.                             ->addDefaultsIfNotSet()
  137.                             ->children()
  138.                                 ->arrayNode('item')
  139.                                     ->info('Add additional items to menu')
  140.                                     ->defaultValue([])
  141.                                     ->prototype('array')
  142.                                         ->children()
  143.                                             ->scalarNode('permission')->info('Permission to restrict the menu item to.')->end()
  144.                                             ->scalarNode('route')->info('Route for link of menu item')->end()
  145.                                             ->scalarNode('menuIcon')->info('CSS class for icon')->example('glyphicon glyphicon-flag')->end()
  146.                                             ->scalarNode('menuName')->info('Tooltip text for menu item')->end()
  147.                                         ->end()
  148.                                     ->end()
  149.                                 ->end()
  150.                             ->end()
  151.                         ->end()
  152.                         ->arrayNode('filter_sidebar')
  153.                             ->info('Settings for filter-sidebar of DAM Frontend')
  154.                             ->addDefaultsIfNotSet()
  155.                             ->children()
  156.                                 ->booleanNode('open_by_default')
  157.                                 ->info('Display filter-sidebar by default')
  158.                                 ->defaultFalse()
  159.                                 ->end()
  160.                             ->end()
  161.                         ->end()
  162.                     ->end()
  163.                 ->end()
  164.                 ->arrayNode('user')
  165.                     ->info('Settings for user access to DAM Frontend.')
  166.                     ->children()
  167.                         ->scalarNode('guest')->info('Configure pimcore user name for public access. If not configured, public access is disabled.')->end()
  168.                     ->end()
  169.                 ->end()
  170.                 ->append($this->buildBackendNodeMetadata())
  171.                 ->arrayNode('customize')
  172.                     ->info('Options to customize DAM frontend appearance.')
  173.                     ->children()
  174.                         ->variableNode('css')
  175.                             ->info('Paths to custom CSS files to be injected into DAM backend, e.g. [/static/css/custom.css, ...]')
  176.                             ->validate()
  177.                                 ->ifTrue(function ($v) {
  178.                                     return $v !== null && false === is_string($v) && false === is_array($v);
  179.                                 })
  180.                                 ->thenInvalid('it must either be of type null, a string or an array')
  181.                             ->end()
  182.                         ->end()
  183.                         ->variableNode('js')
  184.                             ->info('Paths to custom JS files to be injected into DAM backend, e.g. [/static/js/custom.js, ...]')
  185.                             ->validate()
  186.                                 ->ifTrue(function ($v) {
  187.                                     return $v !== null && false === is_string($v) && false === is_array($v);
  188.                                 })
  189.                                 ->thenInvalid('it must either be of type null, a string or an array')
  190.                             ->end()
  191.                         ->end()
  192.                     ->end()
  193.                 ->end()
  194.                 ->arrayNode('upload')
  195.                     ->info('Optional upload settings')
  196.                     ->children()
  197.                         ->arrayNode('metadata')
  198.                             ->children()
  199.                                 ->arrayNode('asset')
  200.                                     ->info('Display these metadata fields to enter data directly during upload.')
  201.                                     ->prototype('scalar')->end()
  202.                                 ->end()
  203.                             ->end()
  204.                         ->end()
  205.                     ->end()
  206.                 ->end()
  207.                 ->arrayNode('collection')
  208.                     ->addDefaultsIfNotSet()
  209.                     ->info('Settings for collections')
  210.                     ->children()
  211.                         ->arrayNode('share')
  212.                             ->addDefaultsIfNotSet()
  213.                             ->children()
  214.                                 ->arrayNode('user')
  215.                                     ->addDefaultsIfNotSet()
  216.                                     ->children()
  217.                                         ->arrayNode('hide')
  218.                                             ->defaultValue([])
  219.                                             ->info('Exclude these users from collection sharing')
  220.                                             ->prototype('scalar')->end()
  221.                                         ->end()
  222.                                     ->end()
  223.                                 ->end()
  224.                             ->end()
  225.                         ->end()
  226.                     ->end()
  227.                 ->end()
  228.             ->end()
  229.         ;
  230.         return $backend;
  231.     }
  232.     /**
  233.      * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
  234.      */
  235.     private function buildBackendNodeMetadata()
  236.     {
  237.         $treeBuilder = new TreeBuilder();
  238.         $tree $treeBuilder->root('metadata');
  239.         $tree
  240.             ->info('Configuration of metadata view in detail page.')
  241.             ->addDefaultsIfNotSet()
  242.             ->children()
  243.                 ->arrayNode('hidden')
  244.                     ->info('Hide metadata fields in view')
  245.                     ->prototype('scalar')->end()
  246.                 ->end()
  247.                 ->booleanNode('hideCommon')
  248.                     ->info('Hide common tab')
  249.                     ->defaultFalse()
  250.                 ->end()
  251.                 ->arrayNode('readonly')
  252.                     ->info('List of metadata fields set to read only')
  253.                     ->prototype('scalar')->end()
  254.                 ->end()
  255.                 ->arrayNode('group')
  256.                     ->info('Configuration of tabs for showing metadata')
  257.                     ->prototype('array')
  258.                         ->children()
  259.                             ->scalarNode('title')->info('Title of tab')->end()
  260.                             ->arrayNode('field')
  261.                                 ->info('List of fields to be shown in tab')
  262.                                 ->prototype('scalar')->end()
  263.                             ->end()
  264.                         ->end()
  265.                     ->end()
  266.                 ->end()
  267.                 ->arrayNode('selectable')
  268.                     ->info('Create Dropdowns to fill content of input fields. Key is field name.')
  269.                     ->prototype('array')
  270.                         ->info("
  271.                                my_field_name: 
  272.                                    plugin: 'remove_button'
  273.                                    group: 
  274.                                        - title: 'my title'
  275.                                          field: 
  276.                                            - 'my value1'
  277.                                            - 'my value2'
  278.                         ")
  279.                         ->children()
  280.                             ->scalarNode('plugin')
  281.                                 ->info('Add Plugin for selectize.js')
  282.                                 ->example('dialog_overlay')
  283.                             ->end()
  284.                             ->arrayNode('group')
  285.                                 ->info('Group of select values')
  286.                                 ->prototype('array')
  287.                                     ->children()
  288.                                         ->scalarNode('title')->isRequired()->info('Title of group')->end()
  289.                                         ->arrayNode('field')
  290.                                             ->info('List of values')
  291.                                             ->prototype('scalar')->end()
  292.                                         ->end()
  293.                                     ->end()
  294.                                 ->end()
  295.                             ->end()
  296.                         ->end()
  297.                     ->end()
  298.                 ->end()
  299.                 ->arrayNode('required')
  300.                     ->info('Required metadata fields')
  301.                     ->defaultValue([])
  302.                     ->prototype('array')
  303.                         ->children()
  304.                             ->scalarNode('field')
  305.                                 ->info('Fieldname of required field')
  306.                                 ->example('date_can-be-used-from')
  307.                             ->end()
  308.                             ->scalarNode('whenFieldName')
  309.                                 ->info('Optional: required only when other field has certain value')
  310.                                 ->example('license_image')
  311.                             ->end()
  312.                             ->scalarNode('whenFieldNameValue')
  313.                                 ->example('1')
  314.                             ->end()
  315.                         ->end()
  316.                     ->end()
  317.                 ->end()
  318.             ->end()
  319.         ;
  320.         return $tree;
  321.     }
  322.     /**
  323.      * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
  324.      */
  325.     private function buildFiltersNode()
  326.     {
  327.         $treeBuilder = new TreeBuilder();
  328.         $tree $treeBuilder->root('filters');
  329.         $tree
  330.             ->info('Add array of custom filters for asset listing, array key is field name')
  331.             ->prototype('array')
  332.                 ->info("
  333.                     my_field_name:
  334.                         type: 'Pimcore\Bundle\DamBundle\Dam\Filter\MultiSelect'
  335.                         icon: 'glyphicon glyphicon-flag'
  336.                         singleColumn: true
  337.                         options:
  338.                             - 'value1'
  339.                             - 'value2'
  340.                 ")
  341.                 ->children()
  342.                     ->scalarNode('type')
  343.                         ->isRequired()
  344.                         ->info('Classname of filtertype, see namespace Pimcore\Bundle\DamBundle\Dam\Filter\* or custom implementations')
  345.                     ->end()
  346.                     ->arrayNode('options')
  347.                         ->info('List of available select values')
  348.                         ->prototype('scalar')->end()
  349.                     ->end()
  350.                     ->booleanNode('singleColumn')->info('Show filter select values in single column layout')->end()
  351.                     ->scalarNode('icon')->info('CSS class for icon of filter')->end()
  352.                     ->scalarNode('metadataName')->info('Name of filtered metadata field')->end()
  353.                     ->scalarNode('object')->info('own filter object')->end()
  354.                 ->end()
  355.             ->end()
  356.         ;
  357.         return $tree;
  358.     }
  359.     /**
  360.      * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
  361.      */
  362.     private function buildExtensionNode()
  363.     {
  364.         $treeBuilder = new TreeBuilder();
  365.         $tree $treeBuilder->root('extension');
  366.         $tree
  367.             ->info('Configure Extensions to the DAM Frontend')
  368.             ->addDefaultsIfNotSet()
  369.             ->children()
  370.                 ->arrayNode('imageEditor')
  371.                     ->info('Enable or disable image editor for images. ')
  372.                     ->addDefaultsIfNotSet()
  373.                     ->children()
  374.                         ->booleanNode('enabled')
  375.                             ->defaultFalse()
  376.                         ->end()
  377.                     ->end()
  378.                 ->end()
  379.                 ->arrayNode('shareAcceptTerms')
  380.                     ->addDefaultsIfNotSet()
  381.                     ->info('Configure optional terms accept dialog before downloading assets in Share Frontend.')
  382.                     ->children()
  383.                         ->booleanNode('enabled')
  384.                             ->info('Enable terms accept dialog.')
  385.                             ->defaultFalse()
  386.                         ->end()
  387.                         ->scalarNode('metaDataKeyCopyrightMandatory')
  388.                             ->info('Meta-data key for setting, if copyright acceptance should be activated by default for shares')
  389.                             ->defaultValue('copyright_mandatory')
  390.                         ->end()
  391.                         ->scalarNode('metaDataKeyCopyright')
  392.                             ->info('Meta-data key for copyright text for an asset - if set properly copyright information is copied to share comment automatically when sharing')
  393.                             ->defaultValue('Copyright')
  394.                         ->end()
  395.                     ->end()
  396.                 ->end()
  397.                 ->booleanNode('passAssetsThroughController')
  398.                     ->info(<<<INFO
  399.                 Enable thumbnail delivery in share frontend though controller and not directly with filepath. 
  400.                 This makes it possible to exclude certain IP addresses from accessing whole Pimcore, except the share frontend.
  401.                 Following urls have to be excluded:
  402.                    - /plugin/DAM/?t=
  403.                    - /plugin/DAM/share
  404.                    - /plugin/DAM/static
  405. INFO
  406.                     )
  407.                     ->defaultTrue()
  408.                 ->end()
  409.             ->end()
  410.         ;
  411.         return $tree;
  412.     }
  413.     /**
  414.      * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
  415.      */
  416.     private function buildDownloadNode()
  417.     {
  418.         $treeBuilder = new TreeBuilder();
  419.         $tree $treeBuilder->root('download');
  420.         $tree
  421.             ->info('Configure download options for DAM Frontend.')
  422.             ->children()
  423.                 ->arrayNode('image')
  424.                     ->info('Add predefined thumbnail configurations available for download.')
  425.                     ->prototype('scalar')->end()
  426.                     ->defaultValue(['dam_detail'])
  427.                 ->end()
  428.                 ->arrayNode('video')
  429.                     ->info('Add predefined thumbnail configurations available for download.')
  430.                     ->prototype('scalar')->end()
  431.                     ->defaultValue(['dam_detail'])
  432.                 ->end()
  433.                 ->booleanNode('onlyPresetDownload')
  434.                     ->info('If set to true, image download is only allowed with preset thumbnail configurations, no free configuration possible.')
  435.                     ->defaultFalse()
  436.                 ->end()
  437.             ->end()
  438.         ;
  439.         return $tree;
  440.     }
  441. }