mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-15 09:30:58 +00:00
252 lines
15 KiB
PHP
252 lines
15 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Sylius package.
|
|
*
|
|
* (c) Paweł Jędrzejewski
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Sylius\Bundle\VariationBundle\DependencyInjection;
|
|
|
|
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
|
|
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceChoiceType;
|
|
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceFromIdentifierType;
|
|
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
|
|
use Sylius\Bundle\VariationBundle\Form\Type\OptionTranslationType;
|
|
use Sylius\Bundle\VariationBundle\Form\Type\OptionType;
|
|
use Sylius\Bundle\VariationBundle\Form\Type\OptionValueTranslationType;
|
|
use Sylius\Bundle\VariationBundle\Form\Type\OptionValueType;
|
|
use Sylius\Bundle\VariationBundle\Form\Type\VariantType;
|
|
use Sylius\Component\Product\Model\OptionValueTranslation;
|
|
use Sylius\Component\Product\Model\OptionValueTranslationInterface;
|
|
use Sylius\Component\Resource\Factory\Factory;
|
|
use Sylius\Component\Resource\Factory\TranslatableFactory;
|
|
use Sylius\Component\Product\Model\OptionTranslation;
|
|
use Sylius\Component\Product\Model\OptionTranslationInterface;
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
|
|
|
/**
|
|
* This class contains the configuration information for the bundle.
|
|
*
|
|
* This information is solely responsible for how the different configuration
|
|
* sections are normalized, and merged.
|
|
*
|
|
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
|
*/
|
|
class Configuration implements ConfigurationInterface
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getConfigTreeBuilder()
|
|
{
|
|
$treeBuilder = new TreeBuilder();
|
|
$rootNode = $treeBuilder->root('sylius_variation');
|
|
|
|
$rootNode
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
|
|
->end()
|
|
;
|
|
|
|
$this->addClassesSection($rootNode);
|
|
|
|
return $treeBuilder;
|
|
}
|
|
|
|
/**
|
|
* @param ArrayNodeDefinition $node
|
|
*/
|
|
private function addClassesSection(ArrayNodeDefinition $node)
|
|
{
|
|
$node
|
|
->children()
|
|
->arrayNode('resources')
|
|
->useAttributeAsKey('name')
|
|
->prototype('array')
|
|
->children()
|
|
->scalarNode('variable')->isRequired()->cannotBeEmpty()->end()
|
|
->arrayNode('variant')
|
|
->isRequired()
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->variableNode('options')->end()
|
|
->arrayNode('classes')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('model')->isRequired()->cannotBeEmpty()->end()
|
|
->scalarNode('interface')->isRequired()->cannotBeEmpty()->end()
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
|
|
->scalarNode('repository')->cannotBeEmpty()->end()
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end()
|
|
->arrayNode('form')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('default')->defaultValue(VariantType::class)->cannotBeEmpty()->end()
|
|
->scalarNode('from_identifier')->defaultValue(ResourceFromIdentifierType::class)->cannotBeEmpty()->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('validation_groups')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->arrayNode('default')
|
|
->prototype('scalar')->end()
|
|
->defaultValue(['sylius'])
|
|
->cannotBeEmpty()
|
|
->end()
|
|
->arrayNode('from_identifier')
|
|
->prototype('scalar')->end()
|
|
->defaultValue(['sylius'])
|
|
->cannotBeEmpty()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('option')
|
|
->isRequired()
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->variableNode('options')->end()
|
|
->arrayNode('classes')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('model')->isRequired()->cannotBeEmpty()->end()
|
|
->scalarNode('interface')->isRequired()->cannotBeEmpty()->end()
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
|
|
->scalarNode('repository')->cannotBeEmpty()->end()
|
|
->scalarNode('factory')->defaultValue(TranslatableFactory::class)->end()
|
|
->arrayNode('form')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('default')->defaultValue(OptionType::class)->cannotBeEmpty()->end()
|
|
->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('validation_groups')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->arrayNode('default')
|
|
->prototype('scalar')->end()
|
|
->defaultValue(['sylius'])
|
|
->cannotBeEmpty()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('translation')
|
|
->isRequired()
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->variableNode('options')->end()
|
|
->arrayNode('classes')
|
|
->isRequired()
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('model')->defaultValue(OptionTranslation::class)->cannotBeEmpty()->end()
|
|
->scalarNode('interface')->defaultValue(OptionTranslationInterface::class)->cannotBeEmpty()->end()
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
|
|
->scalarNode('repository')->cannotBeEmpty()->end()
|
|
->scalarNode('factory')->defaultValue(Factory::class)->end()
|
|
->arrayNode('form')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('default')->defaultValue(OptionTranslationType::class)->cannotBeEmpty()->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('validation_groups')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->arrayNode('default')
|
|
->prototype('scalar')->end()
|
|
->defaultValue(['sylius'])
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('option_value')
|
|
->isRequired()
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->variableNode('options')->end()
|
|
->arrayNode('classes')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('model')->isRequired()->cannotBeEmpty()->end()
|
|
->scalarNode('interface')->isRequired()->cannotBeEmpty()->end()
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
|
|
->scalarNode('repository')->cannotBeEmpty()->cannotBeEmpty()->end()
|
|
->scalarNode('factory')->defaultValue(TranslatableFactory::class)->cannotBeEmpty()->end()
|
|
->arrayNode('form')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('default')->defaultValue(OptionValueType::class)->cannotBeEmpty()->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('validation_groups')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->arrayNode('default')
|
|
->prototype('scalar')->end()
|
|
->defaultValue(['sylius'])
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('translation')
|
|
->isRequired()
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->variableNode('option_value')->end()
|
|
->arrayNode('classes')
|
|
->isRequired()
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('model')->defaultValue(OptionValueTranslation::class)->cannotBeEmpty()->end()
|
|
->scalarNode('interface')->defaultValue(OptionValueTranslationInterface::class)->cannotBeEmpty()->end()
|
|
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
|
|
->scalarNode('repository')->cannotBeEmpty()->end()
|
|
->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end()
|
|
->arrayNode('form')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->scalarNode('default')->defaultValue(OptionValueTranslationType::class)->cannotBeEmpty()->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->arrayNode('validation_groups')
|
|
->addDefaultsIfNotSet()
|
|
->children()
|
|
->arrayNode('default')
|
|
->prototype('scalar')->end()
|
|
->defaultValue(['sylius'])
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
->end()
|
|
;
|
|
}
|
|
}
|