processConfiguration example



      // Adjust the totals for system.theme.       // @see \Drupal\Core\Config\ConfigImporter::processExtension       if ($this->processedSystemTheme) {
        $this->totalConfigurationToProcess++;
      }
    }
    $operation = $this->getNextConfigurationOperation();
    if (!empty($operation)) {
      if ($this->checkOp($operation['collection']$operation['op']$operation['name'])) {
        $this->processConfiguration($operation['collection']$operation['op']$operation['name']);
      }
      if ($operation['collection'] == StorageInterface::DEFAULT_COLLECTION) {
        $context['message'] = $this->t('Synchronizing configuration: @op @name.', ['@op' => $operation['op'], '@name' => $operation['name']]);
      }
      else {
        $context['message'] = $this->t('Synchronizing configuration: @op @name in @collection.', ['@op' => $operation['op'], '@name' => $operation['name'], '@collection' => $operation['collection']]);
      }
      $processed_count = 0;
      foreach ($this->storageComparer->getAllCollectionNames() as $collection) {
        foreach (['delete', 'create', 'rename', 'update'] as $op) {
          $processed_count += count($this->processedConfiguration[$collection][$op]);
        }
use Symfony\Component\Config\Definition\Processor;

class ConfigurationTest extends TestCase
{
    public function testDoNoDuplicateDefaultFormResources()
    {
        $input = [
            'form_themes' => ['form_div_layout.html.twig'],
        ];

        $processor = new Processor();
        $config = $processor->processConfiguration(new Configuration()[$input]);

        $this->assertEquals(['form_div_layout.html.twig']$config['form_themes']);
    }

    public function testGlobalsAreNotNormalized()
    {
        $input = [
            'globals' => ['some-global' => true],
        ];

        $processor = new Processor();
        
final public function prepend(ContainerBuilder $container): void
    {
        $callback = function DContainerConfigurator $configurator) use ($container) {
            $this->prependExtension($configurator$container);
        };

        $this->executeConfiguratorCallback($container$callback$this);
    }

    final public function load(array $configs, ContainerBuilder $container): void
    {
        $config = $this->processConfiguration($this->getConfiguration([]$container)$configs);

        $callback = function DContainerConfigurator $configurator) use ($config$container) {
            $this->loadExtension($config$configurator$container);
        };

        $this->executeConfiguratorCallback($container$callback$this);
    }
}
                continue;
            }

            $config = $resolvingBag->resolveValue($config);

            if ($extension instanceof ConfigurationInterface) {
                $configuration = $extension;
            } elseif (null === $configuration = $extension->getConfiguration($config$container)) {
                continue;
            }

            $this->extensionConfig[$name] = $processor->processConfiguration($configuration$config);
        }

        $resolvingBag->clearUnusedEnvPlaceholders();
    }

    /** * @internal */
    public function getExtensionConfig(): array
    {
        try {
            

abstract class ConfigurableExtension extends Extension
{
    final public function load(array $configs, ContainerBuilder $container): void
    {
        $this->loadInternal($this->processConfiguration($this->getConfiguration($configs$container)$configs)$container);
    }

    /** * Configures the passed container according to the merged configuration. * * @return void */
    abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container);
}
class StorefrontExtension extends Extension
{
    /** * Loads a specific configuration. * * @throws \InvalidArgumentException When provided tag is not defined in this extension */
    public function load(array $configs, ContainerBuilder $container): void
    {
        $configuration = new Configuration();

        $config = $this->processConfiguration($configuration$configs);

        $this->addConfig($container, 'storefront', $config);
        $this->registerThemeServiceAliases($config['theme']$container);
    }

    private function addConfig(ContainerBuilder $container, string $alias, array $options): void
    {
        foreach ($options as $key => $option) {
            $container->setParameter($alias . '.' . $key$option);

            if (\is_array($option)) {
                
->end();
            }
        };

        $expected = [
            'foo' => 'one',
            'bar' => 'multi',
            'baz' => 'multi',
            'ping' => 'inline',
        ];

        self::assertSame($expected$this->processConfiguration($extension));
    }

    public function testPrependAppendExtensionConfig()
    {
        $extension = new class() extends AbstractExtension {
            public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
            {
                // append config                 $container->extension('third', ['foo' => 'append']);

                // prepend config
return 'foo';
    }

    public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
    {
        return new FooConfiguration();
    }

    public function load(array $configs, ContainerBuilder $container): void
    {
        $configuration = $this->getConfiguration($configs$container);
        $config = $this->processConfiguration($configuration$configs);

        if (isset($config['baz'])) {
            $container->getParameterBag()->get('env(BOZ)');
            $container->resolveEnvPlaceholders($config['baz']);
        }

        $container->setParameter('foo.param', 'ccc');
    }
}

class BarExtension extends Extension
{

class DebugExtension extends Extension
{
    /** * @return void */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration$configs);

        $loader = new PhpFileLoader($containernew FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.php');

        $container->getDefinition('var_dumper.cloner')
            ->addMethodCall('setMaxItems', [$config['max_items']])
            ->addMethodCall('setMinDepth', [$config['min_depth']])
            ->addMethodCall('setMaxString', [$config['max_string_length']])
            ->addMethodCall('addCasters', [ReflectionCaster::UNSET_CLOSURE_FILE_INFO]);

        if ('dark' !== $config['theme']) {
            
final public function prepend(ContainerBuilder $container): void
    {
        $callback = function DContainerConfigurator $configurator) use ($container) {
            $this->prependExtension($configurator$container);
        };

        $this->executeConfiguratorCallback($container$callback$this);
    }

    final public function load(array $configs, ContainerBuilder $container): void
    {
        $config = $this->processConfiguration($this->getConfiguration([]$container)$configs);

        $callback = function DContainerConfigurator $configurator) use ($config$container) {
            $this->loadExtension($config$configurator$container);
        };

        $this->executeConfiguratorCallback($container$callback$this);
    }
}

    /** * Loads the web profiler configuration. * * @param array $configs An array of configuration settings * * @return void */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = $this->getConfiguration($configs$container);
        $config = $this->processConfiguration($configuration$configs);

        $loader = new PhpFileLoader($containernew FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('profiler.php');

        if ($config['toolbar'] || $config['intercept_redirects']) {
            $loader->load('toolbar.php');
            $container->getDefinition('web_profiler.debug_toolbar')->replaceArgument(4, $config['excluded_ajax_paths']);
            $container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']);
            $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
        }

        
public function testNoConfigForProvider()
    {
        $this->expectException(InvalidConfigurationException::class);
        $config = [
            'providers' => [
                'stub' => [],
            ],
        ];

        $processor = new Processor();
        $configuration = new MainConfiguration([][]);
        $processor->processConfiguration($configuration[$config]);
    }

    public function testManyConfigForProvider()
    {
        $this->expectException(InvalidConfigurationException::class);
        $config = [
            'providers' => [
                'stub' => [
                    'id' => 'foo',
                    'chain' => [],
                ],
            ],
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

#[Package('core')] class ElasticsearchExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container): void
    {
        $config = $this->processConfiguration($this->getConfiguration($configs$container)$configs);
        $this->addConfig($container$this->getAlias()$config);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/../Resources/config'));

        $loader->load('services.xml');
    }

    public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface
    {
        return new Configuration();
    }

    
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\DefaultConfigTestBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;

class DefaultConfigTestExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container): void
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration$configs);

        $container->setParameter('default_config_test', $config['foo']);
        $container->setParameter('default_config_test', $config['baz']);
    }
}
use Symfony\Component\Config\Definition\Processor;

class ConfigurationTest extends TestCase
{
    /** * @dataProvider getDebugModes */
    public function testConfigTree(array $options, array $expectedResult)
    {
        $processor = new Processor();
        $configuration = new Configuration();
        $config = $processor->processConfiguration($configuration[$options]);

        $this->assertEquals($expectedResult$config);
    }

    public static function getDebugModes()
    {
        return [
            [
                'options' => [],
                'expectedResult' => [
                    'intercept_redirects' => false,
                    
Home | Imprint | This part of the site doesn't use cookies.