當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。