Symfony\Component\DependencyInjection\ContainerBuilder::prependExtensionConfig PHP Method

prependExtensionConfig() public method

Prepends a config array to the configs of the given extension.
public prependExtensionConfig ( string $name, array $config )
$name string The name of the extension
$config array The config to set
    public function prependExtensionConfig($name, array $config)
    {
        if (!isset($this->extensionConfigs[$name])) {
            $this->extensionConfigs[$name] = array();
        }

        array_unshift($this->extensionConfigs[$name], $config);
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function prepend(ContainerBuilder $container)
 {
     $bundles = $container->getParameter('kernel.bundles');
     $configs = $container->getExtensionConfig($this->getAlias());
     $config = $this->processConfiguration(new Configuration(), $configs);
     if ($config['theme']['form']) {
         if (isset($bundles['TwigBundle'])) {
             $container->prependExtensionConfig('twig', ['form' => ['resources' => [$config['template']['form']]]]);
         } else {
             throw new InvalidConfigurationException('You need to enable Twig Bundle to theme form or set the configuration of flob_foundation.theme.form to false');
         }
     }
     if ($config['theme']['knp_menu']) {
         if (isset($bundles['TwigBundle']) && isset($bundles['KnpMenuBundle'])) {
             $container->prependExtensionConfig('knp_menu', ['twig' => ['template' => $config['template']['knp_menu']]]);
         } else {
             throw new InvalidConfigurationException('You need to enable Twig Bundle and KNP Menu Bundle to theme menu or set the configuration of flob_foundation.theme.knp_menu to false');
         }
     }
     if ($config['theme']['knp_paginator']) {
         if (isset($bundles['TwigBundle']) && isset($bundles['KnpPaginatorBundle'])) {
             $container->prependExtensionConfig('knp_paginator', ['template' => ['pagination' => $config['template']['knp_paginator']]]);
         } else {
             throw new InvalidConfigurationException('You need to enable Twig Bundle and KNP Paginator Bundle to theme pagination or set the configuration of flob_foundation.theme.knp_paginator to false');
         }
     }
     if ($config['theme']['pagerfanta']) {
         if (isset($bundles['TwigBundle']) && isset($bundles['WhiteOctoberPagerfantaBundle'])) {
             $container->prependExtensionConfig('white_october_pagerfanta', ['default_view' => $config['template']['pagerfanta']]);
         } else {
             throw new InvalidConfigurationException('You need to enable Twig Bundle and WhiteOctober Pagerfanta Bundle to theme pagination or set the configuration of flob_foundation.theme.pagerfanta to false');
         }
     }
 }
All Usage Examples Of Symfony\Component\DependencyInjection\ContainerBuilder::prependExtensionConfig