本文整理匯總了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::getExtensionConfigs方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerBuilder::getExtensionConfigs方法的具體用法?PHP ContainerBuilder::getExtensionConfigs怎麽用?PHP ContainerBuilder::getExtensionConfigs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::getExtensionConfigs方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
$classes = array();
foreach ($container->getExtensionConfigs() as $name => $configs) {
list($namespace, $tag) = explode(':', $name);
$extension = $container->getExtension($namespace);
if ($extension instanceof Extension) {
$classes = array_merge($classes, $extension->getClassesToCompile());
}
}
$container->setParameter('kernel.compiled_classes', array_unique($classes));
}
示例2: process
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
$parameters = $container->getParameterBag()->all();
$definitions = $container->getDefinitions();
$aliases = $container->getAliases();
foreach ($container->getExtensionConfigs() as $name => $configs) {
list($namespace, $tag) = explode(':', $name);
$extension = $container->getExtension($namespace);
$tmpContainer = new ContainerBuilder($container->getParameterBag());
$tmpContainer->addObjectResource($extension);
$extension->load($tag, $configs, $tmpContainer);
$container->merge($tmpContainer);
}
$container->addDefinitions($definitions);
$container->addAliases($aliases);
$container->getParameterBag()->add($parameters);
}
示例3: merge
/**
* Merges a ContainerBuilder with the current ContainerBuilder configuration.
*
* Service definitions overrides the current defined ones.
*
* But for parameters, they are overridden by the current ones. It allows
* the parameters passed to the container constructor to have precedence
* over the loaded ones.
*
* $container = new ContainerBuilder(array('foo' => 'bar'));
* $loader = new LoaderXXX($container);
* $loader->load('resource_name');
* $container->register('foo', new stdClass());
*
* In the above example, even if the loaded resource defines a foo
* parameter, the value will still be 'bar' as defined in the ContainerBuilder
* constructor.
*/
public function merge(ContainerBuilder $container)
{
if (true === $this->isFrozen()) {
throw new \LogicException('Cannot merge on a frozen container.');
}
$this->addDefinitions($container->getDefinitions());
$this->addAliases($container->getAliases());
$this->addInterfaceInjectors($container->getInterfaceInjectors());
$this->parameterBag->add($container->getParameterBag()->all());
foreach ($container->getResources() as $resource) {
$this->addResource($resource);
}
foreach ($container->getExtensionConfigs() as $name => $configs) {
if (isset($this->extensionConfigs[$name])) {
$this->extensionConfigs[$name] = array_merge($this->extensionConfigs[$name], $configs);
} else {
$this->extensionConfigs[$name] = $configs;
}
}
}