当前位置: 首页>>代码示例>>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;未经允许,请勿转载。