本文整理汇总了PHP中Symfony\Components\DependencyInjection\BuilderConfiguration::getAliases方法的典型用法代码示例。如果您正苦于以下问题:PHP BuilderConfiguration::getAliases方法的具体用法?PHP BuilderConfiguration::getAliases怎么用?PHP BuilderConfiguration::getAliases使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Components\DependencyInjection\BuilderConfiguration
的用法示例。
在下文中一共展示了BuilderConfiguration::getAliases方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: merge
/**
* Merges a BuilderConfiguration with the current one.
*
* @param BuilderConfiguration $configuration
*
* @return BuilderConfiguration The current instance
*/
public function merge(BuilderConfiguration $configuration = null)
{
if (null === $configuration) {
return;
}
$this->addDefinitions($configuration->getDefinitions());
$this->addAliases($configuration->getAliases());
$this->addParameters($configuration->getParameters());
foreach ($configuration->getResources() as $resource) {
$this->addResource($resource);
}
return $this;
}
示例2: array
$t->is($configuration->getAlias('bar'), 'foo', '->setAlias() defines a new alias');
$t->ok($configuration->hasAlias('bar'), '->hasAlias() returns true if the alias is defined');
$t->ok(!$configuration->hasAlias('baba'), '->hasAlias() returns false if the alias is not defined');
try
{
$configuration->getAlias('baba');
$t->fail('->getAlias() throws an \InvalidArgumentException if the alias does not exist');
}
catch (\InvalidArgumentException $e)
{
$t->pass('->getAlias() throws an \InvalidArgumentException if the alias does not exist');
}
$configuration->setAlias('barbar', 'foofoo');
$t->is($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo'), '->getAliases() returns an array of all defined aliases');
$configuration->addAliases(array('foo' => 'bar'));
$t->is($configuration->getAliases(), array('bar' => 'foo', 'barbar' => 'foofoo', 'foo' => 'bar'), '->addAliases() adds some aliases');
// ->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition()
$t->diag('->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition()');
$configuration = new BuilderConfiguration();
$definitions = array(
'foo' => new Definition('FooClass'),
'bar' => new Definition('BarClass'),
);
$configuration->setDefinitions($definitions);
$t->is($configuration->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions');
$t->ok($configuration->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists');
$t->ok(!$configuration->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist');
示例3: testAliases
public function testAliases()
{
$configuration = new BuilderConfiguration();
$configuration->setAlias('bar', 'foo');
$this->assertEquals('foo', $configuration->getAlias('bar'), '->setAlias() defines a new alias');
$this->assertTrue($configuration->hasAlias('bar'), '->hasAlias() returns true if the alias is defined');
$this->assertFalse($configuration->hasAlias('baba'), '->hasAlias() returns false if the alias is not defined');
try {
$configuration->getAlias('baba');
$this->fail('->getAlias() throws an \\InvalidArgumentException if the alias does not exist');
} catch (\Exception $e) {
$this->assertInstanceOf('\\InvalidArgumentException', $e, '->getAlias() throws an \\InvalidArgumentException if the alias does not exist');
$this->assertEquals('The service alias "baba" does not exist.', $e->getMessage(), '->getAlias() throws an \\InvalidArgumentException if the alias does not exist');
}
$configuration->setAlias('barbar', 'foofoo');
$this->assertEquals(array('bar' => 'foo', 'barbar' => 'foofoo'), $configuration->getAliases(), '->getAliases() returns an array of all defined aliases');
$configuration->addAliases(array('foo' => 'bar'));
$this->assertEquals(array('bar' => 'foo', 'barbar' => 'foofoo', 'foo' => 'bar'), $configuration->getAliases(), '->addAliases() adds some aliases');
}