本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::isFrozen方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::isFrozen方法的具体用法?PHP ContainerBuilder::isFrozen怎么用?PHP ContainerBuilder::isFrozen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::isFrozen方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* @param string $id
* @param mixed $service
*/
public static function set($id, $service)
{
if (self::$container === null || self::$container->isFrozen()) {
self::load();
}
self::$container->set($id, $service);
$definition = new Definition(get_class($service));
self::$container->setDefinition($id, $definition);
}
示例2: runCommand
/**
* Runs a command and returns the exit status.
*
* If an output manager is not provided, a new one will be created. The
* new output stream will use a memory stream, and the instance will be
* set as the `$output` argument by reference.
*
* @param InputInterface $input The input manager.
* @param OutputInterface &$output The output manager.
*
* @return integer The exit status.
*/
public function runCommand(InputInterface $input = null, OutputInterface &$output = null)
{
if ($this->container instanceof ContainerBuilder && !$this->container->isFrozen()) {
$this->container->compile();
}
if (null === $output) {
$output = new StreamOutput(fopen('php://memory', 'r+'));
}
return $this->application->run($input, $output);
}
示例3: dump
public function dump(array $options = array())
{
$this->reflectionObject = new ReflectionObject($this);
$options = array_merge(array('class' => 'ProjectServiceContainer', 'base_class' => '\\Nucleus\\DependencyInjection\\BaseServiceContainer', 'namespace' => ''), $options);
$code = $this->call('startClass', $options['class'], $options['base_class'], $options['namespace']);
$code .= $this->addCustom($options);
if ($this->container->isFrozen()) {
$code .= $this->call('addFrozenConstructor');
} else {
$code .= $this->call('addConstructor');
}
$code .= $this->call('addServices') . $this->call('addDefaultParametersMethod') . $this->call('endClass') . $this->call('addProxyClasses');
return $code;
}
示例4: getService
/**
* @param $id The service id
* @return object
*/
private function getService($id)
{
if (!$this->serviceContainer->isFrozen()) {
throw new \RuntimeException(sprintf('The Service "%s" can not be accessed. Maybe you forgot to call the "build" method?', $id));
}
return $this->serviceContainer->get($id);
}
示例5: getService
private function getService($name)
{
if (!$this->serviceContainer->isFrozen()) {
throw new \RuntimeException(sprintf('The service with ID "%s" cannot be accessed before the application is built'));
}
if (!$this->serviceContainer->has($name)) {
throw new \RuntimeException(sprintf('The service with ID "%s" is not registered'));
}
return $this->serviceContainer->get($name);
}
示例6: __construct
/**
* {@inheritdoc}
*/
public function __construct(ContainerBuilder $container)
{
if (!$container->isFrozen()) {
@trigger_error('Dumping an uncompiled ContainerBuilder is deprecated since version 3.3 and will not be supported anymore in 4.0. Compile the container beforehand.', E_USER_DEPRECATED);
}
parent::__construct($container);
$this->inlinedDefinitions = new \SplObjectStorage();
}
示例7: testGetParameters
/**
* Tests that parameter processing works properly.
*
* @covers ::getParameters
* @covers ::prepareParameters
* @covers ::escape
* @covers ::dumpValue
* @covers ::getReferenceCall
*
* @dataProvider getParametersDataProvider
*/
public function testGetParameters($parameters, $definition_parameters, $is_frozen)
{
$this->containerDefinition['parameters'] = $definition_parameters;
$this->containerDefinition['frozen'] = $is_frozen;
$parameter_bag = new ParameterBag($parameters);
$this->containerBuilder->getParameterBag()->willReturn($parameter_bag);
$this->containerBuilder->isFrozen()->willReturn($is_frozen);
if (isset($parameters['reference'])) {
$definition = new Definition('\\stdClass');
$this->containerBuilder->getDefinition('referenced_service')->willReturn($definition);
}
$this->assertEquals($this->containerDefinition, $this->dumper->getArray(), 'Expected definition matches dump.');
}
示例8: doRun
public function doRun(InputInterface $input, OutputInterface $output)
{
if (!$this->container->isFrozen()) {
$this->loadConfigurationFile($input);
$this->registerExtensions();
$this->container->compile();
$eventDispatcher = $this->container->get('event_dispatcher');
if ($eventDispatcher instanceof ContainerAwareEventDispatcher) {
$this->setDispatcher($eventDispatcher);
}
$this->registerCommands();
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
$shell = new Shell($this);
$shell->run();
return 0;
}
}
if (true === $input->hasParameterOption(array('--init'))) {
$this->add($this->container->get('phpzone.phpzone.console.command.init'));
$input = new ArrayInput(array('command' => 'phpzone:init'));
}
return parent::doRun($input, $output);
}
示例9: 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();
}
}
示例10: isFrozen
public function isFrozen()
{
return $this->delegate->isFrozen();
}