本文整理汇总了PHP中Symfony\Component\DependencyInjection\Container::setParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::setParameter方法的具体用法?PHP Container::setParameter怎么用?PHP Container::setParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Container
的用法示例。
在下文中一共展示了Container::setParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(Container $container)
{
$container["data_collectors.swiftmailer.message_logger"] = function () {
return new \Swift_Plugins_MessageLogger();
};
$container["data_collectors.swiftmailer.collector_container"] = function (Container $app) {
$container = new SymfonyContainer();
$container->setParameter("swiftmailer.mailers", ["default" => $app["swiftmailer.options"]]);
$container->setParameter("swiftmailer.default_mailer", "default");
$container->setParameter("swiftmailer.mailer.default.spool.enabled", $app["swiftmailer.use_spool"]);
$container->set("swiftmailer.mailer.default.plugin.messagelogger", $app["data_collectors.swiftmailer.message_logger"]);
return $container;
};
$container->extend('mailer', function (\Swift_Mailer $mailer, Container $container) {
$mailer->registerPlugin($container['data_collectors.swiftmailer.message_logger']);
return $mailer;
});
$container->extend('data_collectors', function (array $collectors, Container $container) {
$collectors['swiftmailer'] = function ($container) {
return new MessageDataCollector($container["data_collectors.swiftmailer.collector_container"]);
};
return $collectors;
});
$container->extend('data_collector.templates', function ($templates) {
$templates[] = ['swiftmailer', '@Swiftmailer/Collector/swiftmailer.html.twig'];
return $templates;
});
$container->extend('twig.loader.filesystem', function (\Twig_Loader_Filesystem $loader) {
$loader->addPath(dirname(dirname((new \ReflectionClass(MessageDataCollector::class))->getFileName())) . '/Resources/views', 'Swiftmailer');
return $loader;
});
}
示例2: testDefaultConfig
/**
* @dataProvider getDebugModes
*/
public function testDefaultConfig($debug)
{
$this->container->setParameter('kernel.debug', $debug);
$extension = new WebProfilerExtension();
$extension->load(array(array()), $this->container);
$this->assertFalse($this->container->has('web_profiler.debug_toolbar'));
$this->assertSaneContainer($this->getDumpedContainer());
}
示例3: testToolbarConfig
/**
* @dataProvider getDebugModes
*/
public function testToolbarConfig($debug)
{
$this->container->setParameter('kernel.debug', $debug);
$extension = new WebProfilerExtension();
$extension->load(array(array('toolbar' => $debug)), $this->container);
$this->assertTrue($debug === $this->container->has('web_profiler.debug_toolbar'), '->load() registers web_profiler.debug_toolbar only when toolbar is true');
$this->assertSaneContainer($this->getDumpedContainer());
}
示例4: buildContainer
/**
* @return Container
*/
private function buildContainer(\Swift_Transport $transport, \Swift_Transport $realTransport, $name = 'default')
{
$mailer = new \Swift_Mailer($transport);
$container = new Container();
$container->set(sprintf('swiftmailer.mailer.%s', $name), $mailer);
$container->set(sprintf('swiftmailer.mailer.%s.transport.real', $name), $realTransport);
$container->setParameter('swiftmailer.mailers', array($name => $mailer));
$container->setParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name), true);
return $container;
}
示例5: testBuild
/**
* @dataProvider menuStructureProvider
* @param array $options
*/
public function testBuild($options)
{
$this->container->setParameter('oro_menu_config', $options);
$this->configurationBuilder->setContainer($this->container);
$menu = new MenuItem('navbar', $this->factory);
$this->configurationBuilder->build($menu, array(), 'navbar');
$this->assertCount(2, $menu->getChildren());
$this->assertEquals($options['tree']['navbar']['type'], $menu->getExtra('type'));
$this->assertCount(count($options['tree']['navbar']['children']['user_user_show']['children']), $menu->getChild('user_user_show'));
$this->assertEquals('user_user_show', $menu->getChild('user_user_show')->getName());
}
示例6: setUp
/**
* @return void
*/
public function setUp()
{
// create container
$this->container = new Container();
// create pid directory
$this->pidDirectory = sys_get_temp_dir() . '/FFreitasBrCommandLockBundle/pid_directory';
$fs = new Filesystem();
if (!$fs->exists($this->pidDirectory)) {
$fs->mkdir($this->pidDirectory);
}
// configure container
$this->container->setParameter($this->configurationsParameterKey, array($this->pidDirectorySetting => $this->pidDirectory, $this->exceptionsListSetting => $this->exceptionsList));
}
示例7: setUp
protected function setUp()
{
/**
* Add the test type to the factory and
* the form to the container
*/
$factory = new FormFactoryBuilder();
$factory->addExtension(new CoreExtension());
$factory->addType(new TestType());
/**
* Construct the container
*/
$container = new Container();
$container->set("thelia.form_factory_builder", $factory);
$container->set("thelia.translator", new Translator($container));
$container->setParameter("thelia.parser.forms", $definition = array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
$request = new Request();
$requestStack = new RequestStack();
$requestStack->push($request);
$request->setSession(new Session(new MockArraySessionStorage()));
$container->set("request", $request);
$container->set("request_stack", $requestStack);
$container->set("thelia.forms.validator_builder", new ValidatorBuilder());
$container->set("event_dispatcher", new EventDispatcher());
$this->factory = new TheliaFormFactory($requestStack, $container, $definition);
}
示例8: testBuildWithOptionsAndRenderer
/**
*/
public function testBuildWithOptionsAndRenderer()
{
$menuConfig = $this->getMenuConfigYamlArray();
$this->helper->expects($this->once())->method('render')->with($this->containsOnlyInstancesOf('Knp\\Menu\\MenuItem'), $this->equalTo(['type' => 'some_menu']), $this->equalTo('some_renderer'))->will($this->returnValue('menu'));
$this->container->setParameter('oro_menu_config', $menuConfig);
$this->menuExtension->render(['navbar', 'user_user_show'], ['type' => 'some_menu'], 'some_renderer');
}
示例9: setUp
protected function setUp()
{
$this->controller = $controller = $this->getMock("Thelia\\Controller\\BaseController", ["getParser", "render", "renderRaw"]);
/**
* Reset static :: $formDefinition on controllers
*/
$this->definitionReflection = $reflection = (new \ReflectionObject($this->controller))->getProperty('formDefinition');
$reflection->setAccessible(true);
$this->formDefinition = $reflection->getValue();
$reflection->setValue(null);
/**
* Add the test type to the factory and
* the form to the container
*/
$factory = new FormFactoryBuilder();
$factory->addExtension(new CoreExtension());
$factory->addType(new TestType());
/**
* Construct the container
*/
$container = new Container();
$container->set("thelia.form_factory_builder", $factory);
$container->set("thelia.translator", new Translator($container));
$container->setParameter("thelia.parser.forms", array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
$request = new Request();
$request->setSession(new Session(new MockArraySessionStorage()));
$container->set("request", $request);
$container->set("thelia.forms.validator_builder", new ValidatorBuilder());
$container->set("event_dispatcher", new EventDispatcher());
$this->controller->setContainer($container);
}
示例10: getIntegration
/**
* @return SymfonyIntegration
*/
private function getIntegration()
{
$container = new Container();
$container->setParameter('plehatron_limoncello', []);
$integration = new SymfonyIntegration();
$integration->setContainer($container);
return $integration;
}
示例11: getContainer
/**
* Returns a valid Container
*
* @return \Symfony\Component\DependencyInjection\Container
*/
protected function getContainer(MockGenerator $mg, Pheanstalk $pheanstalk)
{
$container = new Container();
$container->setParameter('kernel.root_dir', sys_get_temp_dir());
$container->set('pheanstalk', $pheanstalk);
$container->set('logger', $mg->getLoggerMock());
$container->set('pheanstalk.queue.tube_collection', $this->mg->getTubeColletionMock(array($mg->getTubeMock())));
return $container;
}
示例12: testGetSetParameter
public function testGetSetParameter()
{
$sc = new Container(new ParameterBag(array('foo' => 'bar')));
$sc->setParameter('bar', 'foo');
$this->assertEquals('foo', $sc->getParameter('bar'), '->setParameter() sets the value of a new parameter');
$sc->setParameter('foo', 'baz');
$this->assertEquals('baz', $sc->getParameter('foo'), '->setParameter() overrides previously set parameter');
$sc->setParameter('Foo', 'baz1');
$this->assertEquals('baz1', $sc->getParameter('foo'), '->setParameter() converts the key to lowercase');
$this->assertEquals('baz1', $sc->getParameter('FOO'), '->getParameter() converts the key to lowercase');
try {
$sc->getParameter('baba');
$this->fail('->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
} catch (\Exception $e) {
$this->assertInstanceOf('\\InvalidArgumentException', $e, '->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
$this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
}
}
示例13: getContainer
protected function getContainer()
{
$kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
$twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
$container = new Container();
$container->set('kernel', $kernel);
$container->set('twig', $twig);
$container->setParameter('kernel.root_dir', sys_get_temp_dir());
return $container;
}
示例14: testGetRedisClient
/**
* @see \Cosma\Bundle\TestingBundle\TestCase\Traits\RedisTrait::getRedisClient
*/
public function testGetRedisClient()
{
$container = new Container();
$container->setParameter('cosma_testing.redis.scheme', 'tcp');
$container->setParameter('cosma_testing.redis.host', '127.0.0.1');
$container->setParameter('cosma_testing.redis.port', 6379);
$container->setParameter('cosma_testing.redis.database', 13);
$container->setParameter('cosma_testing.redis.timeout', 5.0);
$kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->setMethods(['getContainer'])->getMockForAbstractClass();
$kernel->expects($this->any())->method('getContainer')->will($this->returnValue($container));
$testCaseTrait = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\TestCase\\Traits\\RedisTrait')->disableOriginalConstructor()->setMethods(['getKernel'])->getMockForTrait();
$testCaseTrait->expects($this->any())->method('getKernel')->will($this->returnValue($kernel));
$reflectionClass = new \ReflectionClass($testCaseTrait);
$reflectionMethod = $reflectionClass->getMethod('getRedisClient');
$reflectionMethod->setAccessible(true);
/** @type Client $redisClient */
$redisClient = $reflectionMethod->invoke($testCaseTrait);
$this->assertInstanceOf('\\Predis\\Client', $redisClient);
return [$testCaseTrait, $reflectionClass, $kernel, $container];
}
示例15: testGetSolariumClient
/**
* @see \Cosma\Bundle\TestingBundle\TestCase\Traits\SolrTrait::getSolariumClient
*/
public function testGetSolariumClient()
{
$container = new Container();
$container->setParameter('cosma_testing.solarium.host', '127.0.0.1');
$container->setParameter('cosma_testing.solarium.port', 8080);
$container->setParameter('cosma_testing.solarium.path', '/solr');
$container->setParameter('cosma_testing.solarium.core', 'test');
$container->setParameter('cosma_testing.solarium.timeout', 10);
$kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->setMethods(['getContainer'])->getMockForAbstractClass();
$kernel->expects($this->once())->method('getContainer')->will($this->returnValue($container));
$testCaseTrait = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\TestCase\\Traits\\SolrTrait')->disableOriginalConstructor()->setMethods(['getKernel'])->getMockForTrait();
$testCaseTrait->expects($this->once())->method('getKernel')->will($this->returnValue($kernel));
$reflectionClass = new \ReflectionClass($testCaseTrait);
$reflectionMethod = $reflectionClass->getMethod('getSolariumClient');
$reflectionMethod->setAccessible(true);
/** @type Client $solariumClient */
$solariumClient = $reflectionMethod->invoke($testCaseTrait);
$this->assertInstanceOf('\\Solarium\\Core\\Client\\Client', $solariumClient);
$this->assertEquals(['scheme' => 'http', 'host' => '127.0.0.1', 'port' => 8080, 'path' => '/solr', 'core' => 'test', 'timeout' => 10, 'key' => 'localhostTesting'], $solariumClient->getEndpoint()->getOptions());
return [$testCaseTrait, $reflectionClass];
}