当前位置: 首页>>代码示例>>PHP>>正文


PHP BuilderConfiguration::setParameters方法代码示例

本文整理汇总了PHP中Symfony\Components\DependencyInjection\BuilderConfiguration::setParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP BuilderConfiguration::setParameters方法的具体用法?PHP BuilderConfiguration::setParameters怎么用?PHP BuilderConfiguration::setParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Components\DependencyInjection\BuilderConfiguration的用法示例。


在下文中一共展示了BuilderConfiguration::setParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetGetParameters

 public function testSetGetParameters()
 {
     $configuration = new BuilderConfiguration();
     $this->assertEquals(array(), $configuration->getParameters(), '->getParameters() returns an empty array if no parameter has been defined');
     $configuration->setParameters(array('foo' => 'bar'));
     $this->assertEquals(array('foo' => 'bar'), $configuration->getParameters(), '->setParameters() sets the parameters');
     $configuration->setParameters(array('bar' => 'foo'));
     $this->assertEquals(array('bar' => 'foo'), $configuration->getParameters(), '->setParameters() overrides the previous defined parameters');
     $configuration->setParameters(array('Bar' => 'foo'));
     $this->assertEquals(array('bar' => 'foo'), $configuration->getParameters(), '->setParameters() converts the key to lowercase');
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:11,代码来源:BuilderConfigurationTest.php

示例2: BuilderConfiguration

$t->is($configuration->getDefinition('foo')->getClass(), 'BazClass', '->merge() overrides already defined services');

$configuration = new BuilderConfiguration();
$configuration->addResource($a = new FileResource('foo.xml'));
$config = new BuilderConfiguration();
$config->addResource($b = new FileResource('foo.yml'));
$configuration->merge($config);
$t->is($configuration->getResources(), array($a, $b), '->merge() merges resources');

// ->setParameters() ->getParameters()
$t->diag('->setParameters() ->getParameters()');

$configuration = new BuilderConfiguration();
$t->is($configuration->getParameters(), array(), '->getParameters() returns an empty array if no parameter has been defined');

$configuration->setParameters(array('foo' => 'bar'));
$t->is($configuration->getParameters(), array('foo' => 'bar'), '->setParameters() sets the parameters');

$configuration->setParameters(array('bar' => 'foo'));
$t->is($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() overrides the previous defined parameters');

$configuration->setParameters(array('Bar' => 'foo'));
$t->is($configuration->getParameters(), array('bar' => 'foo'), '->setParameters() converts the key to lowercase');

// ->setParameter() ->getParameter()
$t->diag('->setParameter() ->getParameter() ');

$configuration = new BuilderConfiguration(array(), array('foo' => 'bar'));
$configuration->setParameter('bar', 'foo');
$t->is($configuration->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter');
开发者ID:nicolasmartin,项目名称:symfony,代码行数:30,代码来源:BuilderConfigurationTest.php

示例3: array

$config->setParameters(array('foo' => 'bar'));
$container->merge($config);
$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->merge() merges current parameters with the loaded ones');
$container = new Builder(array('bar' => 'foo', 'foo' => 'baz'));
$config = new BuilderConfiguration();
$config->setParameters(array('foo' => 'bar'));
$container->merge($config);
$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'baz'), '->merge() does not change the already defined parameters');
$container = new Builder(array('bar' => 'foo'));
$config = new BuilderConfiguration();
$config->setParameters(array('foo' => '%bar%'));
$container->merge($config);
$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones');
$container = new Builder(array('bar' => 'foo'));
$config = new BuilderConfiguration();
$config->setParameters(array('foo' => '%bar%', 'baz' => '%foo%'));
$container->merge($config);
$t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), '->merge() evaluates the values of the parameters towards already defined ones');
$container = new Builder();
$container->register('foo', 'FooClass');
$container->register('bar', 'BarClass');
$config = new BuilderConfiguration();
$config->setDefinition('baz', new Definition('BazClass'));
$config->setAlias('alias_for_foo', 'foo');
$container->merge($config);
$t->is(array_keys($container->getDefinitions()), array('foo', 'bar', 'baz'), '->merge() merges definitions already defined ones');
$t->is($container->getAliases(), array('alias_for_foo' => 'foo'), '->merge() registers defined aliases');
$container = new Builder();
$container->register('foo', 'FooClass');
$config->setDefinition('foo', new Definition('BazClass'));
$container->merge($config);
开发者ID:pablosik,项目名称:symfony,代码行数:31,代码来源:BuilderTest.php

示例4: testMerge

 public function testMerge()
 {
     $container = new Builder();
     $container->merge(null);
     $this->assertEquals(array(), $container->getParameters(), '->merge() accepts null as an argument');
     $this->assertEquals(array(), $container->getDefinitions(), '->merge() accepts null as an argument');
     $container = new Builder(array('bar' => 'foo'));
     $config = new BuilderConfiguration();
     $config->setParameters(array('foo' => 'bar'));
     $container->merge($config);
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'bar'), $container->getParameters(), '->merge() merges current parameters with the loaded ones');
     $container = new Builder(array('bar' => 'foo', 'foo' => 'baz'));
     $config = new BuilderConfiguration();
     $config->setParameters(array('foo' => 'bar'));
     $container->merge($config);
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'baz'), $container->getParameters(), '->merge() does not change the already defined parameters');
     $container = new Builder(array('bar' => 'foo'));
     $config = new BuilderConfiguration();
     $config->setParameters(array('foo' => '%bar%'));
     $container->merge($config);
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo'), $container->getParameters(), '->merge() evaluates the values of the parameters towards already defined ones');
     $container = new Builder(array('bar' => 'foo'));
     $config = new BuilderConfiguration();
     $config->setParameters(array('foo' => '%bar%', 'baz' => '%foo%'));
     $container->merge($config);
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), $container->getParameters(), '->merge() evaluates the values of the parameters towards already defined ones');
     $container = new Builder();
     $container->register('foo', 'FooClass');
     $container->register('bar', 'BarClass');
     $config = new BuilderConfiguration();
     $config->setDefinition('baz', new Definition('BazClass'));
     $config->setAlias('alias_for_foo', 'foo');
     $container->merge($config);
     $this->assertEquals(array('foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
     $this->assertEquals(array('alias_for_foo' => 'foo'), $container->getAliases(), '->merge() registers defined aliases');
     $container = new Builder();
     $container->register('foo', 'FooClass');
     $config->setDefinition('foo', new Definition('BazClass'));
     $container->merge($config);
     $this->assertEquals('BazClass', $container->getDefinition('foo')->getClass(), '->merge() overrides already defined services');
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:41,代码来源:BuilderTest.php


注:本文中的Symfony\Components\DependencyInjection\BuilderConfiguration::setParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。