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


PHP ContainerBuilder::reset方法代碼示例

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


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

示例1: logResult

 /**
  * @param ContainerBuilder $container
  * @param array $loggerStore
  * @param float $totalTime
  */
 private function logResult(ContainerBuilder $container, array $loggerStore, float $totalTime)
 {
     $container->reset();
     /** @var Logger $logger */
     $logger = $container->get('logger');
     $logger->debug('DIC: start', ['channel' => 'dic']);
     foreach ($loggerStore as $log) {
         $logger->debug($log, ['channel' => 'dic']);
     }
     $logger->debug(sprintf('DIC: %0.2fms total time', $totalTime * 1000), ['channel' => 'dic']);
 }
開發者ID:brainexe,項目名稱:core,代碼行數:16,代碼來源:GlobalCompilerPass.php

示例2: getContainer

 protected function getContainer()
 {
     if (isset(self::$containers[$this->getTestBasePath()])) {
         // Use cached container (creating a new container from yml is too slow)
         $this->setContainer(self::$containers[$this->getTestBasePath()]);
         $this->container->reset();
         $this->configureContainer();
     } elseif (!$this->container) {
         // Create new container
         $this->setContainer(new ContainerBuilder());
         $this->configureContainer();
         $locator = new FileLocator($this->getTestBasePath());
         $this->loader = new YamlFileLoader($this->container, $locator);
         $this->loader->load('config.yml');
         try {
             $this->loader->load('config.local.yml');
         } catch (\InvalidArgumentException $e) {
             // No local config found
         }
         // Cache container
         self::$containers[$this->getTestBasePath()] = $this->container;
     }
     return $this->container;
 }
開發者ID:lastzero,項目名稱:test-tools,代碼行數:24,代碼來源:UnitTestCase.php

示例3: testContainerWithoutCloning

 public function testContainerWithoutCloning()
 {
     $container = new ContainerBuilder();
     $locator = new FileLocator(__DIR__);
     $loader = new YamlFileLoader($container, $locator);
     $loader->load('container.yml');
     $container->setParameter('fixture.path', __DIR__ . '/foo/');
     $container->setParameter('base.path', __DIR__);
     $this->assertEquals(__DIR__ . '/foo/', $container->getParameter('fixture.path'));
     $this->assertEquals(__DIR__, $container->getParameter('base.path'));
     $buzz = $container->get('buzz.fixture');
     $this->assertInstanceOf('TestTools\\Buzz\\Client', $buzz);
     $this->assertEquals($container->getParameter('fixture.path'), $buzz->getFixturePath());
     $container->reset();
     $container->setParameter('fixture.path', __DIR__ . '/bar/');
     $container->setParameter('base.path', __DIR__);
     $this->assertEquals(__DIR__ . '/bar/', $container->getParameter('fixture.path'));
     $this->assertEquals(__DIR__, $container->getParameter('base.path'));
     $buzz = $container->get('buzz.fixture');
     $this->assertInstanceOf('TestTools\\Buzz\\Client', $buzz);
     $this->assertEquals($container->getParameter('fixture.path'), $buzz->getFixturePath());
 }
開發者ID:lastzero,項目名稱:test-tools,代碼行數:22,代碼來源:UnitTestCaseTest.php


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