本文整理汇总了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']);
}
示例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;
}
示例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());
}