本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::setAliases方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::setAliases方法的具体用法?PHP ContainerBuilder::setAliases怎么用?PHP ContainerBuilder::setAliases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::setAliases方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Processes the ContainerBuilder to resolve parameter placeholders.
*
* @param ContainerBuilder $container
*
* @throws ParameterNotFoundException
*/
public function process(ContainerBuilder $container)
{
$parameterBag = $container->getParameterBag();
foreach ($container->getDefinitions() as $id => $definition) {
try {
$definition->setClass($parameterBag->resolveValue($definition->getClass()));
$definition->setFile($parameterBag->resolveValue($definition->getFile()));
$definition->setArguments($parameterBag->resolveValue($definition->getArguments()));
if ($definition->getFactoryClass(false)) {
$definition->setFactoryClass($parameterBag->resolveValue($definition->getFactoryClass(false)));
}
$factory = $definition->getFactory();
if (is_array($factory) && isset($factory[0])) {
$factory[0] = $parameterBag->resolveValue($factory[0]);
$definition->setFactory($factory);
}
$calls = array();
foreach ($definition->getMethodCalls() as $name => $arguments) {
$calls[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($arguments);
}
$definition->setMethodCalls($calls);
$definition->setProperties($parameterBag->resolveValue($definition->getProperties()));
} catch (ParameterNotFoundException $e) {
$e->setSourceId($id);
throw $e;
}
}
$aliases = array();
foreach ($container->getAliases() as $name => $target) {
$aliases[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($target);
}
$container->setAliases($aliases);
$parameterBag->resolve();
}
示例2: getContainerBuilders
public static function getContainerBuilders()
{
$builder1 = new ContainerBuilder();
$builder1->setDefinitions(self::getContainerDefinitions());
$builder1->setAliases(self::getContainerAliases());
return array('builder_1' => $builder1);
}
示例3: process
public function process(ContainerBuilder $container)
{
$this->parameterBag = $container->getParameterBag();
foreach ($container->getDefinitions() as $definition) {
$definition->setClass($this->resolveValue($definition->getClass()));
$definition->setFile($this->resolveValue($definition->getFile()));
$definition->setArguments($this->resolveValue($definition->getArguments()));
$calls = array();
foreach ($definition->getMethodCalls() as $name => $arguments) {
$calls[$this->resolveValue($name)] = $this->resolveValue($arguments);
}
$definition->setMethodCalls($calls);
}
$aliases = array();
foreach ($container->getAliases() as $name => $target) {
$aliases[$this->resolveValue($name)] = $this->resolveValue($target);
}
$container->setAliases($aliases);
$injectors = array();
foreach ($container->getInterfaceInjectors() as $class => $injector) {
$injector->setClass($this->resolveValue($injector->getClass()));
$injectors[$this->resolveValue($class)] = $injector;
}
$container->setInterfaceInjectors($injectors);
$parameterBag = $container->getParameterBag();
foreach ($parameterBag->all() as $key => $value) {
$parameterBag->set($key, $this->resolveValue($value));
}
}
示例4: process
/**
* Processes the ContainerBuilder to resolve parameter placeholders.
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
$this->parameterBag = $container->getParameterBag();
foreach ($container->getDefinitions() as $id => $definition) {
try {
$definition->setClass($this->resolveValue($definition->getClass()));
$definition->setFile($this->resolveValue($definition->getFile()));
$definition->setArguments($this->resolveValue($definition->getArguments()));
$calls = array();
foreach ($definition->getMethodCalls() as $name => $arguments) {
$calls[$this->resolveValue($name)] = $this->resolveValue($arguments);
}
$definition->setMethodCalls($calls);
$definition->setProperties($this->resolveValue($definition->getProperties()));
} catch (ParameterNotFoundException $e) {
$e->setSourceId($id);
throw $e;
}
}
$aliases = array();
foreach ($container->getAliases() as $name => $target) {
$aliases[$this->resolveValue($name)] = $this->resolveValue($target);
}
$container->setAliases($aliases);
$parameterBag = $container->getParameterBag();
foreach ($parameterBag->all() as $key => $value) {
try {
$parameterBag->set($key, $this->resolveValue($value));
} catch (ParameterNotFoundException $e) {
$e->setSourceKey($key);
throw $e;
}
}
}
示例5: testAddAliases
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::addAliases
*/
public function testAddAliases()
{
$builder = new ContainerBuilder();
$builder->setAliases(array('bar' => 'foo'));
$builder->addAliases(array('foobar' => 'foo'));
$aliases = $builder->getAliases();
$this->assertTrue(isset($aliases['bar']));
$this->assertTrue(isset($aliases['foobar']));
}
示例6: cloneContainer
private function cloneContainer()
{
$parameterBag = new ParameterBag($this->container->getParameterBag()->all());
$container = new ContainerBuilder($parameterBag);
$container->setDefinitions($this->container->getDefinitions());
$container->setAliases($this->container->getAliases());
$container->setResources($this->container->getResources());
foreach ($this->container->getExtensions() as $extension) {
$container->registerExtension($extension);
}
return $container;
}
示例7: setAliases
public function setAliases(array $aliases)
{
return $this->delegate->setAliases($aliases);
}
示例8: testAddAliases
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::addAliases
*/
public function testAddAliases()
{
$builder = new ContainerBuilder();
$builder->setAliases(array('bar' => 'foo'));
$builder->addAliases(array('foobar' => 'foo'));
$this->assertEquals(array('bar' => 'foo', 'foobar' => 'foo'), $builder->getAliases(), '->getAliases() returns all service aliases');
}