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


PHP ContainerBuilder::compile方法代码示例

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


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

示例1: array

 /**
  * @param null $configPath
  * @param array $configFilenames
  */
 function __construct($configPath = null, $configFilenames = array())
 {
     $configPath = $configPath == null ? __DIR__ . '/../../../../../../app/config' : $configPath;
     $this->container = new ContainerBuilder();
     // Load app parameters and config files into container
     $loader = new YamlFileLoader($this->container, new FileLocator($configPath));
     $loader->load('parameters.yml');
     foreach ($configFilenames as $filename) {
         $loader->load($filename);
     }
     $appName = $this->container->getParameter('application_name');
     $appVersion = $this->container->getParameter('application_version');
     parent::__construct($appName, $appVersion);
     // Set dispatcher definition, register listeners and subscribers
     $dispatcherDef = $this->container->register('event_dispatcher', 'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher');
     $dispatcherDef->addArgument($this->container);
     $this->registerEventListeners();
     $this->container->compile();
     // Once container is compiled we can get the event_dispatcher from dic
     $this->dispatcher = $this->container->get('event_dispatcher');
     // Add console commands (services console.command tagged)
     foreach ($this->getTaggedCommands() as $id) {
         $command = $this->container->get($id);
         $this->add($command);
     }
 }
开发者ID:rodrigodiez,项目名称:symfony-rich-console,代码行数:30,代码来源:Application.php

示例2: testTemplatingConfiguration

 public function testTemplatingConfiguration()
 {
     $this->loadConfiguration($this->container, 'simple');
     $this->container->compile();
     $helper = $this->container->get('fm_tinymce.templating.helper');
     $this->assertInstanceOf('FM\\TinyMCEBundle\\Templating\\TinyMCEHelper', $helper);
 }
开发者ID:helios-ag,项目名称:FMTinyMCEBundle,代码行数:7,代码来源:TinyMCEExtensionTest.php

示例3: testReconnectConfiguration

 public function testReconnectConfiguration()
 {
     $this->initContainer();
     $this->loadConfiguration($this->container, 'reconnect_config');
     $this->container->compile();
     $this->assert->boolean($this->container->has('m6_redis'))->isIdenticalTo(true)->and()->object($serviceRedis = $this->container->get('m6_redis'))->isInstanceOf('M6Web\\Bundle\\RedisBundle\\Redis\\Redis');
 }
开发者ID:agallou,项目名称:RedisBundle,代码行数:7,代码来源:M6WebRedisExtension.php

示例4: build

 /**
  * Builds the container.
  * @param array $parameters
  */
 public function build($parameters = array())
 {
     // sort array by key to generate the container name
     ksort($parameters);
     // needed for new packages installed
     $composerClass = array_filter(get_declared_classes(), function ($item) {
         if (0 === strpos($item, 'ComposerAutoloaderInit')) {
             return true;
         }
     });
     $composerClass = array_pop($composerClass);
     // generate hash
     $parametersHash = md5(serialize($parameters) . $composerClass);
     $containerClass = 'Container' . $parametersHash;
     $isDebug = true;
     $file = sprintf('%s/ladybug_cache/%s.php', sys_get_temp_dir(), $parametersHash);
     $containerConfigCache = new ConfigCache($file, $isDebug);
     if (!$containerConfigCache->isFresh()) {
         $this->initializeContainer();
         $this->loadServices();
         $this->loadThemes();
         $this->loadPlugins();
         $this->setParameters($parameters);
         $this->container->compile();
         $dumper = new PhpDumper($this->container);
         $containerConfigCache->write($dumper->dump(array('class' => $containerClass)), $this->container->getResources());
     } else {
         require_once $file;
         $this->container = new $containerClass();
     }
 }
开发者ID:ankalagon,项目名称:ladybug,代码行数:35,代码来源:Application.php

示例5: 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

示例6: compile

 /**
  * @return SymfonyContainerBuilder
  */
 public function compile()
 {
     $this->registerServices($this->parameters['services']);
     $this->builder->setResourceTracking(false);
     $this->builder->compile();
     return $this->builder;
 }
开发者ID:ChiarilloMassimo,项目名称:PixelTracking,代码行数:10,代码来源:ContainerBuilder.php

示例7: boot

 protected function boot()
 {
     if ($this->hasBooted()) {
         return;
     }
     // Nothing to do
     if ($this->debug) {
         $this->setContainer(new ContainerBuilder(new ParameterBag($this->getAppParameters())));
         $this->loadContainerConfiguration();
     } else {
         $filename = $this->getContainerCacheFilename();
         if (file_exists($filename)) {
             require_once $filename;
             $this->setContainer(new CachedContainer());
         } else {
             $this->setContainer(new ContainerBuilder(new ParameterBag($this->getAppParameters())));
             $this->loadContainerConfiguration();
             $this->container->compile();
             if ($this->containerIsCacheable()) {
                 $dumper = new PhpDumper($this->container);
                 file_put_contents($filename, $dumper->dump());
             }
         }
     }
 }
开发者ID:lastzero,项目名称:symlex-core,代码行数:25,代码来源:App.php

示例8: testIfAServiceDefinitionIsNotCorrectAnExceptionWillBeThrown

 public function testIfAServiceDefinitionIsNotCorrectAnExceptionWillBeThrown()
 {
     $loader = new XmlFileLoader($this->container, new FileLocator(__DIR__ . '/Fixtures'));
     $loader->load('incorrect_service_definitions.xml');
     $this->setExpectedException('Matthias\\SymfonyServiceDefinitionValidator\\Exception\\InvalidServiceDefinitionsException');
     $this->container->compile();
 }
开发者ID:seclu,项目名称:symfony-service-definition-validator,代码行数:7,代码来源:FunctionalTest.php

示例9: 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

示例10: it_gets_cleaners

 /**
  * @test
  */
 public function it_gets_cleaners()
 {
     $this->createCleaner('cleaner1');
     $this->createCleaner('cleaner2');
     $this->createCleaner('cleaner3');
     $this->container->compile();
     $this->resolverContainsCleaners(array('cleaner1', 'cleaner2', 'cleaner3'));
 }
开发者ID:cmodijk,项目名称:LongRunning,代码行数:11,代码来源:RegisterCleanersPassTest.php

示例11: it_gets_fingers_crossed_handlers

 /**
  * @test
  */
 public function it_gets_fingers_crossed_handlers()
 {
     $this->createFingersCrossedHandler('monolog.handler.handler1');
     $this->createFingersCrossedHandler('monolog.handler.handler2');
     $this->createFingersCrossedHandler('monolog.handler.handler3');
     $this->container->compile();
     $this->resolverContainsFingersCrossedHandlers(array('monolog.handler.handler1', 'monolog.handler.handler2', 'monolog.handler.handler3'));
 }
开发者ID:cmodijk,项目名称:LongRunning,代码行数:11,代码来源:MonologCleanersPassFingersCrossedTest.php

示例12: __construct

 public function __construct()
 {
     $this->container = new ContainerBuilder();
     $this->container->addCompilerPass(new CommandBusCompilerPass());
     $this->container->addCompilerPass(new QueryBusCompilerPass());
     $this->getConfigServices();
     $this->container->compile();
 }
开发者ID:iron-web,项目名称:php-git-hooks,代码行数:8,代码来源:AppKernel.php

示例13: 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

示例14: testSharedService

 public function testSharedService()
 {
     $this->loader->load(__DIR__ . '/Fixtures/sharedService.yml');
     $this->container->compile();
     $one = $this->container->get('foo');
     $two = $this->container->get('foo');
     $this->assertNotSame($one, $two);
 }
开发者ID:janmarek,项目名称:autowiring-bundle,代码行数:8,代码来源:SharedServiceIntegrationTest.php

示例15: it_configures_a_chain_of_buses_according_to_the_given_priorities

 /**
  * @test
  */
 public function it_configures_a_chain_of_buses_according_to_the_given_priorities()
 {
     $this->createBusDefinition('middleware100', 100);
     $this->createBusDefinition('middleware-100', -100);
     $this->createBusDefinition('middleware200', 200);
     $this->container->compile();
     $this->commandBusContainsMiddlewares(array('middleware200', 'middleware100', 'middleware-100'));
 }
开发者ID:hmlb,项目名称:ddd-bundle,代码行数:11,代码来源:ConfigureMiddlewaresTest.php


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