vendor/coreshop/rule-bundle/DependencyInjection/Configuration.php line 34

Open in your IDE?
  1. <?php
  2. /**
  3.  * CoreShop.
  4.  *
  5.  * This source file is subject to the GNU General Public License version 3 (GPLv3)
  6.  * For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
  7.  * files that are distributed with this source code.
  8.  *
  9.  * @copyright  Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
  10.  * @license    https://www.coreshop.org/license     GNU General Public License version 3 (GPLv3)
  11. */
  12. namespace CoreShop\Bundle\RuleBundle\DependencyInjection;
  13. use CoreShop\Bundle\ResourceBundle\Controller\ResourceController;
  14. use CoreShop\Bundle\ResourceBundle\CoreShopResourceBundle;
  15. use CoreShop\Component\Resource\Factory\Factory;
  16. use CoreShop\Component\Rule\Model\Action;
  17. use CoreShop\Component\Rule\Model\ActionInterface;
  18. use CoreShop\Component\Rule\Model\Condition;
  19. use CoreShop\Component\Rule\Model\ConditionInterface;
  20. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  21. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  22. use Symfony\Component\Config\Definition\ConfigurationInterface;
  23. final class Configuration implements ConfigurationInterface
  24. {
  25.     /**
  26.      * {@inheritdoc}
  27.      */
  28.     public function getConfigTreeBuilder()
  29.     {
  30.         $treeBuilder = new TreeBuilder();
  31.         $rootNode $treeBuilder->root('core_shop_rule');
  32.         $rootNode
  33.             ->children()
  34.                 ->scalarNode('driver')->defaultValue(CoreShopResourceBundle::DRIVER_DOCTRINE_ORM)->end()
  35.             ->end();
  36.         $this->addModelsSection($rootNode);
  37.         $this->addPimcoreResourcesSection($rootNode);
  38.         return $treeBuilder;
  39.     }
  40.     /**
  41.      * @param ArrayNodeDefinition $node
  42.      */
  43.     private function addModelsSection(ArrayNodeDefinition $node)
  44.     {
  45.         $node
  46.             ->children()
  47.                 ->arrayNode('resources')
  48.                     ->addDefaultsIfNotSet()
  49.                     ->children()
  50.                         ->arrayNode('rule_condition')
  51.                             ->addDefaultsIfNotSet()
  52.                             ->children()
  53.                                 ->variableNode('options')->end()
  54.                                 ->arrayNode('classes')
  55.                                     ->addDefaultsIfNotSet()
  56.                                     ->children()
  57.                                         ->scalarNode('model')->defaultValue(Condition::class)->cannotBeEmpty()->end()
  58.                                         ->scalarNode('interface')->defaultValue(ConditionInterface::class)->cannotBeEmpty()->end()
  59.                                         ->scalarNode('admin_controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
  60.                                         ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end()
  61.                                         ->scalarNode('repository')->cannotBeEmpty()->end()
  62.                                         //->scalarNode('form')->defaultValue(CurrencyType::class)->cannotBeEmpty()->end()
  63.                                     ->end()
  64.                                 ->end()
  65.                             ->end()
  66.                         ->end()
  67.                         ->arrayNode('rule_action')
  68.                             ->addDefaultsIfNotSet()
  69.                             ->children()
  70.                                 ->variableNode('options')->end()
  71.                                 ->arrayNode('classes')
  72.                                     ->addDefaultsIfNotSet()
  73.                                     ->children()
  74.                                         ->scalarNode('model')->defaultValue(Action::class)->cannotBeEmpty()->end()
  75.                                         ->scalarNode('interface')->defaultValue(ActionInterface::class)->cannotBeEmpty()->end()
  76.                                         ->scalarNode('admin_controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
  77.                                         ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end()
  78.                                         ->scalarNode('repository')->cannotBeEmpty()->end()
  79.                                         //->scalarNode('form')->defaultValue(CurrencyType::class)->cannotBeEmpty()->end()
  80.                                     ->end()
  81.                                 ->end()
  82.                             ->end()
  83.                         ->end()
  84.                     ->end()
  85.                 ->end()
  86.             ->end();
  87.     }
  88.     /**
  89.      * @param ArrayNodeDefinition $node
  90.      */
  91.     private function addPimcoreResourcesSection(ArrayNodeDefinition $node)
  92.     {
  93.         $node->children()
  94.             ->arrayNode('pimcore_admin')
  95.                 ->addDefaultsIfNotSet()
  96.                 ->children()
  97.                     ->arrayNode('js')
  98.                         ->useAttributeAsKey('name')
  99.                         ->prototype('scalar')->end()
  100.                     ->end()
  101.                     ->arrayNode('css')
  102.                         ->useAttributeAsKey('name')
  103.                         ->prototype('scalar')->end()
  104.                     ->end()
  105.                     ->arrayNode('editmode_js')
  106.                         ->useAttributeAsKey('name')
  107.                         ->prototype('scalar')->end()
  108.                     ->end()
  109.                     ->arrayNode('editmode_css')
  110.                         ->useAttributeAsKey('name')
  111.                         ->prototype('scalar')->end()
  112.                     ->end()
  113.                 ->end()
  114.             ->end()
  115.         ->end();
  116.     }
  117. }