本文整理汇总了PHP中Symfony\Components\DependencyInjection\BuilderConfiguration::getResources方法的典型用法代码示例。如果您正苦于以下问题:PHP BuilderConfiguration::getResources方法的具体用法?PHP BuilderConfiguration::getResources怎么用?PHP BuilderConfiguration::getResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Components\DependencyInjection\BuilderConfiguration
的用法示例。
在下文中一共展示了BuilderConfiguration::getResources方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Definition
$configuration->setDefinition('foobar', $foo = new Definition('FooBarClass'));
$t->is($configuration->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined');
$t->ok($configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference');
$configuration->addDefinitions($defs = array('foobar' => new Definition('FooBarClass')));
$t->is($configuration->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions');
try
{
$configuration->getDefinition('baz');
$t->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
}
catch (InvalidArgumentException $e)
{
$t->pass('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
}
// ->findDefinition()
$t->diag('->findDefinition()');
$configuration = new BuilderConfiguration(array('foo' => $definition = new Definition('FooClass')));
$configuration->setAlias('bar', 'foo');
$configuration->setAlias('foobar', 'bar');
$t->is($configuration->findDefinition('foobar'), $definition, '->findDefinition() returns a Definition');
// ->addResource() ->getResources()
$t->diag('->addResource() ->getResources()');
$configuration = new BuilderConfiguration();
$configuration->addResource($a = new FileResource('foo.xml'));
$configuration->addResource($b = new FileResource('foo.yml'));
$t->is($configuration->getResources(), array($a, $b), '->getResources() returns an array of resources read for the current configuration');
示例3: testResources
public function testResources()
{
$configuration = new BuilderConfiguration();
$configuration->addResource($a = new FileResource('foo.xml'));
$configuration->addResource($b = new FileResource('foo.yml'));
$this->assertEquals(array($a, $b), $configuration->getResources(), '->getResources() returns an array of resources read for the current configuration');
}
示例4: testResources
/**
* @covers Symfony\Components\DependencyInjection\BuilderConfiguration::getResources
* @covers Symfony\Components\DependencyInjection\BuilderConfiguration::addResource
*/
public function testResources()
{
$configuration = new BuilderConfiguration();
$configuration->addResource($a = new FileResource(self::$fixturesPath . '/xml/services1.xml'));
$configuration->addResource($b = new FileResource(self::$fixturesPath . '/xml/services2.xml'));
$this->assertEquals(array($a, $b), $configuration->getResources(), '->getResources() returns an array of resources read for the current configuration');
}