本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::loadFromExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::loadFromExtension方法的具体用法?PHP ContainerBuilder::loadFromExtension怎么用?PHP ContainerBuilder::loadFromExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::loadFromExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoadExtension
/**
* Test load extension
* @throws \LogicException
* @throws \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
*/
public function testLoadExtension()
{
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
// Check that services have been loaded
static::assertTrue($this->container->has('timestamp.type'));
}
示例2: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->container = new ContainerBuilder();
$extension = new FakerExtension();
$this->container->registerExtension($extension);
$this->container->loadFromExtension($extension->getAlias());
}
示例3: configureContainer
/**
* Configures the container.
*
* You can register extensions:
*
* $c->loadFromExtension('framework', array(
* 'secret' => '%secret%'
* ));
*
* Or services:
*
* $c->register('halloween', 'FooBundle\HalloweenProvider');
*
* Or parameters:
*
* $c->setParameter('halloween', 'lot of fun');
*
* @param ContainerBuilder $c
* @param LoaderInterface $loader
*/
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
{
$session = ['handler_id' => 'session.handler.predis', 'name' => 'santaSession'];
if ($c->getParameter('kernel.environment') === 'test') {
$session['storage_id'] = 'session.storage.filesystem';
$session['handler_id'] = 'session.handler.native_file';
}
$c->loadFromExtension('framework', ['secret' => 'NotSoRandom...:)', 'session' => $session]);
$c->loadFromExtension('twig', ['paths' => [__DIR__ . '/../views/']]);
if (empty($_ENV['SLACK_CLIENT_SECRET']) || empty($_ENV['SLACK_CLIENT_ID'])) {
$_ENV['SLACK_CLIENT_SECRET'] = 'dummy';
$_ENV['SLACK_CLIENT_ID'] = 'dummy';
}
if (empty($_ENV['REDIS_URL'])) {
$_ENV['REDIS_URL'] = 'redis://localhost:6379';
}
// Slack application credentials
$c->setParameter('slack.client_secret', $_ENV['SLACK_CLIENT_SECRET']);
$c->setParameter('slack.client_id', $_ENV['SLACK_CLIENT_ID']);
$controller = $c->register('santa.controller', SantaController::class);
$controller->setAutowired(true);
$controller->addArgument(new Parameter('slack.client_id'));
$controller->addArgument(new Parameter('slack.client_secret'));
$sessionHandler = $c->register('session.handler.predis', Handler::class);
$sessionHandler->setPublic(false);
$sessionHandler->setAutowired(true);
$predis = $c->register('predis', Client::class);
$predis->setPublic(false);
$predis->addArgument($_ENV['REDIS_URL']);
}
示例4: testWithoutConfiguration
public function testWithoutConfiguration()
{
// An extension is only loaded in the container if a configuration is provided for it.
// Then, we need to explicitely load it.
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
$this->assertFalse($this->container->hasParameter('google_tag_manager'));
}
示例5: testLoadExtension
/**
* Test load extension
*/
public function testLoadExtension()
{
$this->container->prependExtensionConfig($this->extension->getAlias(), ['login' => 'XXX']);
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
// Check that services have been loaded
$this->assertTrue($this->container->has('hellosign.client'));
}
示例6: setUp
/**
* {@ineritdoc}
*/
protected function setUp()
{
$this->container = new ContainerBuilder();
$this->container->setParameter('bundle.dir', realpath(__DIR__ . '/../../'));
$this->container->registerExtension($extension = new WidopHttpAdapterExtension());
$this->container->loadFromExtension($extension->getAlias());
$this->container->registerExtension(new RequestLabXitiAnalyticsExtension());
}
开发者ID:RequestLab,项目名称:XitiAnalyticsBundle,代码行数:11,代码来源:AbstractRequestLabXitiAnalyticsExtensionTest.php
示例7: build
/**
* @return \Ikwattro\GithubEvent\EventHandler
*/
public function build()
{
$extension = new GithubEventExtension();
$this->serviceContainer->registerExtension($extension);
$this->serviceContainer->loadFromExtension($extension->getAlias(), $this->getConfiguration());
$this->serviceContainer->compile();
return $this;
}
示例8: testDefaultConfiguration
public function testDefaultConfiguration()
{
// An extension is only loaded in the container if a configuration is provided for it.
// Then, we need to explicitely load it.
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
$this->assertTrue($this->container->getParameterBag()->has('gg_team_breadcrumb'));
}
示例9: initServiceProxyBundle
private function initServiceProxyBundle()
{
$bundle = new OpenClassroomsServiceProxyBundle();
$serviceProxyExtension = $bundle->getContainerExtension();
$this->container->registerExtension($serviceProxyExtension);
$this->container->loadFromExtension('openclassrooms_service_proxy');
$bundle->build($this->container);
}
示例10: build
/**
* @return \Neoxygen\Neogen\Neogen
*/
public function build()
{
$extension = new NeogenExtension();
$this->serviceContainer->registerExtension($extension);
$this->serviceContainer->loadFromExtension($extension->getAlias(), $this->getConfiguration());
$this->serviceContainer->compile();
$this->getParserManager()->registerParser(new YamlFileParser());
$this->getParserManager()->registerParser(new CypherPattern());
return $this;
}
示例11: configureContainer
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
{
// load bundles' configuration
$c->loadFromExtension('framework', ['secret' => '12345', 'profiler' => ['enabled' => true], 'templating' => ['engines' => ['twig']]]);
$c->loadFromExtension('web_profiler', ['toolbar' => true]);
// add configuration parameters
$c->setParameter('mail_sender', 'user@example.com');
// register services
$c->register('app.markdown', 'AppBundle\\Service\\Parser\\Markdown');
}
示例12: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->assetsHelperMock = $this->getMockBuilder('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')->disableOriginalConstructor()->getMock();
$this->routerMock = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
$this->container = new ContainerBuilder();
$this->container->set('templating.helper.assets', $this->assetsHelperMock);
$this->container->set('router', $this->routerMock);
$this->container->setParameter('templating.engines', array('php', 'twig'));
$this->container->registerExtension($extension = new IvoryCKEditorExtension());
$this->container->loadFromExtension($extension->getAlias());
}
示例13: testParameters
public function testParameters()
{
$path = Path::join([DATAFIXTURES_DIR, 'config', 'test-parameters.json']);
$this->locator->locate('test-parameters.json')->willReturn($path);
$this->container->addResource(Argument::that(function (FileResource $resource) use($path) {
return $resource->getResource() === $path;
}))->shouldBeCalled();
$this->container->loadFromExtension('test-parameters', ['name' => 'test'])->shouldBeCalled();
$this->container->setParameter('test', 'value')->shouldBeCalled();
$this->loader->load('test-parameters.json');
}
示例14: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->requestMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
$this->container = new ContainerBuilder();
$this->container->addScope(new Scope('request'));
$this->container->setParameter('templating.engines', array('php', 'twig'));
$this->container->set('request', $this->requestMock);
$this->container->registerExtension(new IvoryGoogleMapExtension());
$this->container->registerExtension($httpAdapterExtension = new WidopHttpAdapterExtension());
$this->container->loadFromExtension($httpAdapterExtension->getAlias());
}
示例15: testLoadWithoutConfiguration
/**
* @test PrestaDeploymentExtension::load()
*/
public function testLoadWithoutConfiguration()
{
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
$this->assertTrue($this->container->has('presta_deployment.manager.configuration'));
$configurationManager = $this->container->get('presta_deployment.manager.configuration');
$this->assertFalse($configurationManager->isOrmEnabled());
$this->assertFalse($configurationManager->isPhpcrEnabled());
$this->assertFalse($configurationManager->isMigrationEnabled());
$this->assertFalse($configurationManager->isDeployRebuildEnabled());
}