當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Container::compile方法代碼示例

本文整理匯總了PHP中Symfony\Component\DependencyInjection\Container::compile方法的典型用法代碼示例。如果您正苦於以下問題:PHP Container::compile方法的具體用法?PHP Container::compile怎麽用?PHP Container::compile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DependencyInjection\Container的用法示例。


在下文中一共展示了Container::compile方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testIsFrozen

 public function testIsFrozen()
 {
     $sc = new Container(new ParameterBag(array('foo' => 'bar')));
     $this->assertFalse($sc->isFrozen(), '->isFrozen() returns false if the parameters are not frozen');
     $sc->compile();
     $this->assertTrue($sc->isFrozen(), '->isFrozen() returns true if the parameters are frozen');
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:7,代碼來源:ContainerTest.php

示例2: getDumpedContainer

 private function getDumpedContainer()
 {
     static $i = 0;
     $class = 'WebProfilerExtensionTestContainer' . $i++;
     $this->container->compile();
     $dumper = new PhpDumper($this->container);
     eval('?>' . $dumper->dump(array('class' => $class)));
     $container = new $class();
     $container->set('kernel', $this->kernel);
     return $container;
 }
開發者ID:nuwe1,項目名稱:symfony,代碼行數:11,代碼來源:WebProfilerExtensionTest.php

示例3: getContainer

 /**
  * Returns ContainerBuilder by including the default file 'containerBuilder.php' from settings directory.
  *
  * @throws \RuntimeException
  */
 protected function getContainer()
 {
     if ($this->innerContainer instanceof ContainerInterface) {
         // Do nothing
     } elseif (!is_readable($this->innerContainer)) {
         throw new RuntimeException(sprintf("Unable to read file %s\n", $this->innerContainer));
     } else {
         // 'containerBuilder.php' file expects $installDir variable to be set by caller
         $installDir = $this->installDir;
         $this->innerContainer = (require_once $this->innerContainer);
     }
     // Compile container if necessary
     if ($this->innerContainer instanceof ContainerBuilder && !$this->innerContainer->isFrozen()) {
         $this->innerContainer->compile();
     }
 }
開發者ID:Pixy,項目名稱:ezpublish-kernel,代碼行數:21,代碼來源:ServiceContainer.php

示例4: compile

 /**
  * Compiles the container.
  *
  * This method passes the container to compiler
  * passes whose job is to manipulate and optimize
  * the container.
  *
  * The main compiler passes roughly do four things:
  *
  *  * The extension configurations are merged;
  *  * Parameter values are resolved;
  *  * The parameter bag is frozen;
  *  * Extension loading is disabled.
  */
 public function compile()
 {
     $compiler = $this->getCompiler();
     if ($this->trackResources) {
         foreach ($compiler->getPassConfig()->getPasses() as $pass) {
             $this->addObjectResource($pass);
         }
     }
     $compiler->compile($this);
     if ($this->trackResources) {
         foreach ($this->definitions as $definition) {
             if ($definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) {
                 $this->addClassResource(new \ReflectionClass($class));
             }
         }
     }
     $this->extensionConfigs = array();
     parent::compile();
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:33,代碼來源:ContainerBuilder.php

示例5: compile

 /**
  * Compiles the container.
  *
  * This method passes the container to compiler
  * passes whose job is to manipulate and optimize
  * the container.
  *
  * The main compiler passes roughly do four things:
  *
  *  * The extension configurations are merged;
  *  * Parameter values are resolved;
  *  * The parameter bag is frozen;
  *  * Extension loading is disabled.
  *
  * @api
  */
 public function compile()
 {
     if (null === $this->compiler) {
         $this->compiler = new Compiler();
     }
     foreach ($this->compiler->getPassConfig()->getPasses() as $pass) {
         $this->addObjectResource($pass);
     }
     $this->compiler->compile($this);
     $this->extensionConfigs = array();
     parent::compile();
 }
開發者ID:hykz,項目名稱:Depot,代碼行數:28,代碼來源:ContainerBuilder.php

示例6: compile

 /**
  * Compiles the container.
  *
  * This method passes the container to compiler
  * passes whose job is to manipulate and optimize
  * the container.
  *
  * The main compiler passes roughly do four things:
  *
  *  * The extension configurations are merged;
  *  * Parameter values are resolved;
  *  * The parameter bag is frozen;
  *  * Extension loading is disabled.
  */
 public function compile()
 {
     $this->compiler->compile($this);
     $this->setExtensionConfigs(array());
     parent::compile();
 }
開發者ID:notbrain,項目名稱:symfony,代碼行數:20,代碼來源:ContainerBuilder.php

示例7: compile

 /**
  * Compiles the container.
  *
  * This method passes the container to compiler
  * passes whose job is to manipulate and optimize
  * the container.
  *
  * The main compiler passes roughly do four things:
  *
  *  * The extension configurations are merged;
  *  * Parameter values are resolved;
  *  * The parameter bag is frozen;
  *  * Extension loading is disabled.
  */
 public function compile()
 {
     $compiler = $this->getCompiler();
     if ($this->trackResources) {
         foreach ($compiler->getPassConfig()->getPasses() as $pass) {
             $this->addObjectResource($pass);
         }
     }
     $compiler->compile($this);
     $this->compiled = true;
     foreach ($this->definitions as $id => $definition) {
         if (!$definition->isPublic()) {
             $this->privates[$id] = true;
         }
         if ($this->trackResources && $definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) {
             $this->addClassResource(new \ReflectionClass($class));
         }
     }
     $this->extensionConfigs = array();
     $bag = $this->getParameterBag();
     parent::compile();
     $this->envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : array();
 }
開發者ID:kmiladi,項目名稱:symfony,代碼行數:37,代碼來源:ContainerBuilder.php

示例8: createTranslator

 protected function createTranslator($em, $cacheDir)
 {
     $listener = new GetDatabaseResourcesListener($this->getORMStorage($em), 'xxxxx');
     $dispatcher = new EventDispatcher();
     $dispatcher->addListener('lexik_translation.event.get_database_resources', array($listener, 'onGetDatabaseResources'));
     $container = new Container();
     $container->set('event_dispatcher', $dispatcher);
     $container->compile();
     $loaderIds = array();
     $options = array('cache_dir' => $cacheDir);
     return new TranslatorMock($container, new MessageSelector(), $loaderIds, $options);
 }
開發者ID:StuartApp,項目名稱:LexikTranslationBundle,代碼行數:12,代碼來源:TranslatorTest.php

示例9: compile

 /**
  * Compiles the container.
  *
  * This method passes the container to compiler
  * passes whose job is to manipulate and optimize
  * the container.
  *
  * The main compiler passes roughly do four things:
  *
  *  * The extension configurations are merged;
  *  * Parameter values are resolved;
  *  * The parameter bag is frozen;
  *  * Extension loading is disabled.
  */
 public function compile()
 {
     if (null === $this->compiler) {
         $this->initializeCompiler();
     }
     $this->compiler->compile($this);
     $this->setExtensionConfigs(array());
     parent::compile();
 }
開發者ID:GromNaN,項目名稱:GitWikiApp,代碼行數:23,代碼來源:ContainerBuilder.php

示例10: dumpContainer

 /**
  * Dump a container
  * @param Container $container
  * @param $class
  * @param $location
  * @param string $baseClass
  * @throws \RuntimeException
  */
 public static function dumpContainer(Container $container, $class, $location, $baseClass = 'Symfony\\Component\\DependencyInjection\\Container')
 {
     if (!file_exists($location)) {
         throw new RuntimeException('Dump location does not exist');
     }
     $container->compile();
     $dumper = new PhpDumper($container);
     file_put_contents(realpath($location) . "/{$class}.php", $dumper->dump(array('class' => $class, 'base_class' => $baseClass)));
 }
開發者ID:camspiers,項目名稱:shared-dependency-injection,代碼行數:17,代碼來源:SharedContainerFactory.php


注:本文中的Symfony\Component\DependencyInjection\Container::compile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。