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


PHP ContainerBuilder::loadFromExtension方法代码示例

本文整理汇总了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'));
 }
开发者ID:Bukashk0zzz,项目名称:TimestampTypeBundle,代码行数:12,代码来源:Bukashk0zzzTimestampTypeExtensionTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->container = new ContainerBuilder();
     $extension = new FakerExtension();
     $this->container->registerExtension($extension);
     $this->container->loadFromExtension($extension->getAlias());
 }
开发者ID:resing,项目名称:ecommerce,代码行数:10,代码来源:ProviderCompilerPassTest.php

示例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']);
 }
开发者ID:hhamon,项目名称:slack-secret-santa,代码行数:50,代码来源:SantaKernel.php

示例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'));
 }
开发者ID:Alltricks,项目名称:GoogleTagManagerBundle,代码行数:8,代码来源:AbstractGoogleTagManagerExtensionTest.php

示例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'));
 }
开发者ID:Bukashk0zzz,项目名称:HelloSignBundle,代码行数:11,代码来源:Bukashk0zzzHelloSignExtensionTest.php

示例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;
 }
开发者ID:ikwattro,项目名称:github-event,代码行数:11,代码来源:EventHandler.php

示例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'));
 }
开发者ID:ggteam,项目名称:breadcrumbbundle,代码行数:8,代码来源:AbstractBreadcrumbBundleExtensionTest.php

示例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);
 }
开发者ID:emilyreese,项目名称:ServiceProxyBundle,代码行数:8,代码来源:ContainerTestUtil.php

示例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;
 }
开发者ID:neoxygen,项目名称:neogen,代码行数:13,代码来源:Neogen.php

示例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');
 }
开发者ID:roman-movchan,项目名称:microkernel,代码行数:10,代码来源:MicroKernel.php

示例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());
 }
开发者ID:jul6art,项目名称:vscms,代码行数:14,代码来源:AbstractIvoryCKEditorExtensionTest.php

示例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');
 }
开发者ID:nanbando,项目名称:core,代码行数:11,代码来源:JsonLoaderTest.php

示例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());
 }
开发者ID:acrobat,项目名称:IvoryGoogleMapBundle,代码行数:14,代码来源:AbstractIvoryGoogleMapExtensionTest.php

示例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());
 }
开发者ID:BenoitLeveque,项目名称:PrestaDeploymentBundle,代码行数:14,代码来源:PrestaDeploymentExtensionTest.php


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