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 |
namespace App\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\DependencyInjection\Extension; class AppExtension extends Extension { public function prepend(ContainerBuilder $container) { $doctrineConfig = array( 'dbal' => array( // your custom database configuration settings ), 'orm' => array( // your custom ORM configuration settings ), ); $container->prependExtensionConfig('doctrine', $doctrineConfig); } }
namespace App\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\DependencyInjection\Extension; class AppExtension extends Extension { public function prepend(ContainerBuilder $container) { $config = array( 'setting_1' => true, 'setting_2' => false, ); $container->prependExtensionConfig('app', $config); } }In both examples, we're using the ContainerBuilder class and its prependExtensionConfig method to modify configuration settings for the Doctrine ORM or our own bundle. The package library being used is the Symfony Dependency Injection component.
public prependExtensionConfig ( string $name, array $config ) | ||
$name | string | The name of the extension |
$config | array | The config to set |