2013-01-05 08:50:11 +00:00
|
|
|
<?php
|
|
|
|
|
2016-12-13 17:37:51 +00:00
|
|
|
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
2013-01-05 08:50:11 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
use Symfony\Component\DependencyInjection\Container;
|
2013-01-05 15:29:42 +00:00
|
|
|
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
|
|
|
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
|
|
|
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
2013-01-05 08:50:11 +00:00
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
|
|
|
|
|
|
|
/**
|
2015-03-24 21:20:39 +00:00
|
|
|
* ProjectServiceContainer.
|
2013-01-05 08:50:11 +00:00
|
|
|
*
|
|
|
|
* This class has been auto-generated
|
|
|
|
* by the Symfony Dependency Injection Component.
|
2017-01-12 22:13:34 +00:00
|
|
|
*
|
|
|
|
* @final since Symfony 3.3
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
|
|
|
class ProjectServiceContainer extends Container
|
|
|
|
{
|
2014-12-03 08:59:38 +00:00
|
|
|
private $parameters;
|
2014-12-04 20:13:58 +00:00
|
|
|
private $targetDirs = array();
|
2017-07-17 21:21:41 +01:00
|
|
|
private $privates = array();
|
2013-12-01 06:04:55 +00:00
|
|
|
|
2013-01-05 08:50:11 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->parameters = $this->getDefaultParameters();
|
|
|
|
|
2017-07-17 21:21:41 +01:00
|
|
|
$this->services = $this->privates = array();
|
2013-05-05 11:11:01 +01:00
|
|
|
$this->methodMap = array(
|
2017-05-20 21:54:17 +01:00
|
|
|
'BAR' => 'getBARService',
|
|
|
|
'BAR2' => 'getBAR2Service',
|
|
|
|
'bar' => 'getBar3Service',
|
|
|
|
'bar2' => 'getBar22Service',
|
2013-05-05 11:11:01 +01:00
|
|
|
'baz' => 'getBazService',
|
2013-11-02 12:45:44 +00:00
|
|
|
'configured_service' => 'getConfiguredServiceService',
|
2016-04-30 11:40:11 +01:00
|
|
|
'configured_service_simple' => 'getConfiguredServiceSimpleService',
|
2014-03-31 16:58:40 +01:00
|
|
|
'decorator_service' => 'getDecoratorServiceService',
|
|
|
|
'decorator_service_with_name' => 'getDecoratorServiceWithNameService',
|
2015-08-07 17:08:40 +01:00
|
|
|
'deprecated_service' => 'getDeprecatedServiceService',
|
2013-05-05 11:11:01 +01:00
|
|
|
'factory_service' => 'getFactoryServiceService',
|
2016-04-30 11:40:11 +01:00
|
|
|
'factory_service_simple' => 'getFactoryServiceSimpleService',
|
2013-05-05 11:11:01 +01:00
|
|
|
'foo' => 'getFooService',
|
|
|
|
'foo.baz' => 'getFoo_BazService',
|
|
|
|
'foo_bar' => 'getFooBarService',
|
|
|
|
'foo_with_inline' => 'getFooWithInlineService',
|
2016-12-13 17:37:51 +00:00
|
|
|
'lazy_context' => 'getLazyContextService',
|
|
|
|
'lazy_context_ignore_invalid_ref' => 'getLazyContextIgnoreInvalidRefService',
|
2013-05-05 11:11:01 +01:00
|
|
|
'method_call1' => 'getMethodCall1Service',
|
2014-04-13 16:18:39 +01:00
|
|
|
'new_factory_service' => 'getNewFactoryServiceService',
|
2014-09-27 17:06:30 +01:00
|
|
|
'service_from_static_method' => 'getServiceFromStaticMethodService',
|
2013-06-04 13:28:00 +01:00
|
|
|
);
|
|
|
|
$this->aliases = array(
|
2013-06-05 10:51:05 +01:00
|
|
|
'alias_for_alias' => 'foo',
|
2013-06-04 13:28:00 +01:00
|
|
|
'alias_for_foo' => 'foo',
|
2014-03-31 16:58:40 +01:00
|
|
|
'decorated' => 'decorator_service_with_name',
|
2013-05-05 11:11:01 +01:00
|
|
|
);
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 15:06:58 +01:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function reset()
|
|
|
|
{
|
|
|
|
$this->privates = array();
|
|
|
|
parent::reset();
|
|
|
|
}
|
|
|
|
|
2014-09-05 10:37:47 +01:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function compile()
|
|
|
|
{
|
2016-08-19 13:18:08 +01:00
|
|
|
throw new LogicException('You cannot compile a dumped container that was already compiled.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function isCompiled()
|
|
|
|
{
|
|
|
|
return true;
|
2014-09-05 10:37:47 +01:00
|
|
|
}
|
|
|
|
|
2017-05-20 21:54:17 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'BAR' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
|
|
|
* @return \stdClass A stdClass instance
|
|
|
|
*/
|
|
|
|
protected function getBARService()
|
|
|
|
{
|
|
|
|
$this->services['BAR'] = $instance = new \stdClass();
|
|
|
|
|
2017-07-17 21:21:41 +01:00
|
|
|
$instance->bar = ($this->services['bar'] ?? $this->getBar3Service());
|
2017-05-20 21:54:17 +01:00
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the 'BAR2' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
|
|
|
* @return \stdClass A stdClass instance
|
|
|
|
*/
|
|
|
|
protected function getBAR2Service()
|
|
|
|
{
|
|
|
|
return $this->services['BAR2'] = new \stdClass();
|
|
|
|
}
|
|
|
|
|
2013-01-05 08:50:11 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'bar' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Bar\FooClass A Bar\FooClass instance
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
2017-05-20 21:54:17 +01:00
|
|
|
protected function getBar3Service()
|
2013-01-05 08:50:11 +00:00
|
|
|
{
|
2017-07-17 21:21:41 +01:00
|
|
|
$a = ($this->services['foo.baz'] ?? $this->getFoo_BazService());
|
2013-01-05 08:50:11 +00:00
|
|
|
|
2013-12-18 17:52:54 +00:00
|
|
|
$this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar'));
|
2013-11-02 12:45:44 +00:00
|
|
|
|
|
|
|
$a->configure($instance);
|
2013-01-05 08:50:11 +00:00
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
2017-05-20 21:54:17 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'bar2' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
|
|
|
* @return \stdClass A stdClass instance
|
|
|
|
*/
|
|
|
|
protected function getBar22Service()
|
|
|
|
{
|
|
|
|
return $this->services['bar2'] = new \stdClass();
|
|
|
|
}
|
|
|
|
|
2013-01-05 09:16:41 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'baz' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Baz A Baz instance
|
2013-01-05 09:16:41 +00:00
|
|
|
*/
|
|
|
|
protected function getBazService()
|
|
|
|
{
|
2017-02-16 22:39:07 +00:00
|
|
|
$this->services['baz'] = $instance = new \Baz();
|
|
|
|
|
2017-07-17 21:21:41 +01:00
|
|
|
$instance->setFoo(($this->services['foo_with_inline'] ?? $this->getFooWithInlineService()));
|
2017-02-16 22:39:07 +00:00
|
|
|
|
|
|
|
return $instance;
|
2013-01-05 09:16:41 +00:00
|
|
|
}
|
|
|
|
|
2013-11-02 12:45:44 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'configured_service' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \stdClass A stdClass instance
|
2013-11-02 12:45:44 +00:00
|
|
|
*/
|
|
|
|
protected function getConfiguredServiceService()
|
|
|
|
{
|
2015-03-23 18:17:24 +00:00
|
|
|
$a = new \ConfClass();
|
2017-07-17 21:21:41 +01:00
|
|
|
$a->setFoo(($this->services['baz'] ?? $this->getBazService()));
|
2015-03-23 18:17:24 +00:00
|
|
|
|
2013-11-02 12:45:44 +00:00
|
|
|
$this->services['configured_service'] = $instance = new \stdClass();
|
|
|
|
|
2015-03-23 18:17:24 +00:00
|
|
|
$a->configureStdClass($instance);
|
2013-11-02 12:45:44 +00:00
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
2016-04-30 11:40:11 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'configured_service_simple' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-29 06:40:45 +01:00
|
|
|
* @return \stdClass A stdClass instance
|
2016-04-30 11:40:11 +01:00
|
|
|
*/
|
|
|
|
protected function getConfiguredServiceSimpleService()
|
|
|
|
{
|
|
|
|
$this->services['configured_service_simple'] = $instance = new \stdClass();
|
|
|
|
|
|
|
|
(new \ConfClass('bar'))->configureStdClass($instance);
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
2014-03-31 16:58:40 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'decorator_service' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \stdClass A stdClass instance
|
2014-03-31 16:58:40 +01:00
|
|
|
*/
|
|
|
|
protected function getDecoratorServiceService()
|
|
|
|
{
|
|
|
|
return $this->services['decorator_service'] = new \stdClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the 'decorator_service_with_name' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \stdClass A stdClass instance
|
2014-03-31 16:58:40 +01:00
|
|
|
*/
|
|
|
|
protected function getDecoratorServiceWithNameService()
|
|
|
|
{
|
|
|
|
return $this->services['decorator_service_with_name'] = new \stdClass();
|
|
|
|
}
|
|
|
|
|
2015-08-07 17:08:40 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'deprecated_service' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-29 06:31:50 +01:00
|
|
|
* @return \stdClass A stdClass instance
|
2015-08-07 17:08:40 +01:00
|
|
|
*
|
2015-08-10 13:35:12 +01:00
|
|
|
* @deprecated The "deprecated_service" service is deprecated. You should stop using it, as it will soon be removed.
|
2015-08-07 17:08:40 +01:00
|
|
|
*/
|
|
|
|
protected function getDeprecatedServiceService()
|
|
|
|
{
|
2015-08-10 13:35:12 +01:00
|
|
|
@trigger_error('The "deprecated_service" service is deprecated. You should stop using it, as it will soon be removed.', E_USER_DEPRECATED);
|
2015-08-07 17:08:40 +01:00
|
|
|
|
|
|
|
return $this->services['deprecated_service'] = new \stdClass();
|
|
|
|
}
|
|
|
|
|
2013-01-05 08:50:11 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'factory_service' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Bar A Bar instance
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
|
|
|
protected function getFactoryServiceService()
|
|
|
|
{
|
2017-07-17 21:21:41 +01:00
|
|
|
return $this->services['factory_service'] = ($this->services['foo.baz'] ?? $this->getFoo_BazService())->getInstance();
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
|
|
|
|
2016-04-30 11:40:11 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'factory_service_simple' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-29 06:40:45 +01:00
|
|
|
* @return \Bar A Bar instance
|
2016-04-30 11:40:11 +01:00
|
|
|
*/
|
|
|
|
protected function getFactoryServiceSimpleService()
|
|
|
|
{
|
|
|
|
return $this->services['factory_service_simple'] = (new \SimpleFactoryClass('foo'))->getInstance();
|
|
|
|
}
|
|
|
|
|
2013-01-05 08:50:11 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'foo' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Bar\FooClass A Bar\FooClass instance
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
|
|
|
protected function getFooService()
|
|
|
|
{
|
2017-07-17 21:21:41 +01:00
|
|
|
$a = ($this->services['foo.baz'] ?? $this->getFoo_BazService());
|
2013-01-05 08:50:11 +00:00
|
|
|
|
2013-12-18 17:52:54 +00:00
|
|
|
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this);
|
2013-01-05 08:50:11 +00:00
|
|
|
|
|
|
|
$instance->foo = 'bar';
|
|
|
|
$instance->moo = $a;
|
2013-11-23 20:44:08 +00:00
|
|
|
$instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar');
|
2017-07-17 21:21:41 +01:00
|
|
|
$instance->setBar(($this->services['bar'] ?? $this->getBar3Service()));
|
2016-11-19 11:21:18 +00:00
|
|
|
$instance->initialize();
|
2013-01-05 08:50:11 +00:00
|
|
|
sc_configure($instance);
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the 'foo.baz' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \BazClass A BazClass instance
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
|
|
|
protected function getFoo_BazService()
|
|
|
|
{
|
2013-12-18 14:16:42 +00:00
|
|
|
$this->services['foo.baz'] = $instance = \BazClass::getInstance();
|
2013-01-05 08:50:11 +00:00
|
|
|
|
2013-12-18 14:16:42 +00:00
|
|
|
\BazClass::configureStatic1($instance);
|
2013-01-05 08:50:11 +00:00
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the 'foo_bar' service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Bar\FooClass A Bar\FooClass instance
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
|
|
|
protected function getFooBarService()
|
|
|
|
{
|
2013-12-18 17:52:54 +00:00
|
|
|
return new \Bar\FooClass();
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 08:13:52 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'foo_with_inline' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Foo A Foo instance
|
2013-01-05 08:13:52 +00:00
|
|
|
*/
|
|
|
|
protected function getFooWithInlineService()
|
|
|
|
{
|
|
|
|
$a = new \Bar();
|
|
|
|
|
2017-01-27 15:27:34 +00:00
|
|
|
$this->services['foo_with_inline'] = $instance = new \Foo();
|
|
|
|
|
2017-02-16 22:39:07 +00:00
|
|
|
$a->pub = 'pub';
|
2017-07-17 21:21:41 +01:00
|
|
|
$a->setBaz(($this->services['baz'] ?? $this->getBazService()));
|
2017-02-16 22:39:07 +00:00
|
|
|
|
2013-01-05 08:13:52 +00:00
|
|
|
$instance->setBar($a);
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
2016-12-13 17:37:51 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'lazy_context' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
|
|
|
* @return \LazyContext A LazyContext instance
|
|
|
|
*/
|
|
|
|
protected function getLazyContextService()
|
|
|
|
{
|
2017-01-29 19:10:36 +00:00
|
|
|
return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () {
|
2017-07-17 21:21:41 +01:00
|
|
|
yield 'k1' => ($this->services['foo.baz'] ?? $this->getFoo_BazService());
|
2017-04-21 10:31:17 +01:00
|
|
|
yield 'k2' => $this;
|
2017-05-19 22:03:53 +01:00
|
|
|
}, 2), new RewindableGenerator(function () {
|
|
|
|
return new \EmptyIterator();
|
|
|
|
}, 0));
|
2016-12-13 17:37:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the 'lazy_context_ignore_invalid_ref' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
|
|
|
* @return \LazyContext A LazyContext instance
|
|
|
|
*/
|
|
|
|
protected function getLazyContextIgnoreInvalidRefService()
|
|
|
|
{
|
2017-01-29 19:10:36 +00:00
|
|
|
return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () {
|
2017-07-17 21:21:41 +01:00
|
|
|
yield 0 => ($this->services['foo.baz'] ?? $this->getFoo_BazService());
|
2017-05-19 22:03:53 +01:00
|
|
|
}, 1), new RewindableGenerator(function () {
|
|
|
|
return new \EmptyIterator();
|
|
|
|
}, 0));
|
2016-12-13 17:37:51 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 08:50:11 +00:00
|
|
|
/**
|
|
|
|
* Gets the 'method_call1' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Bar\FooClass A Bar\FooClass instance
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
|
|
|
protected function getMethodCall1Service()
|
|
|
|
{
|
|
|
|
require_once '%path%foo.php';
|
|
|
|
|
2013-12-18 17:52:54 +00:00
|
|
|
$this->services['method_call1'] = $instance = new \Bar\FooClass();
|
2013-01-05 08:50:11 +00:00
|
|
|
|
2017-07-17 21:21:41 +01:00
|
|
|
$instance->setBar(($this->services['foo'] ?? $this->getFooService()));
|
2013-01-05 08:50:11 +00:00
|
|
|
$instance->setBar(NULL);
|
2017-07-26 07:59:36 +01:00
|
|
|
$instance->setBar((($this->services['foo'] ?? $this->getFooService())->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
|
2013-01-05 08:50:11 +00:00
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
2014-04-13 16:18:39 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'new_factory_service' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \FooBarBaz A FooBarBaz instance
|
2014-04-13 16:18:39 +01:00
|
|
|
*/
|
|
|
|
protected function getNewFactoryServiceService()
|
|
|
|
{
|
2015-03-23 18:17:24 +00:00
|
|
|
$a = new \FactoryClass();
|
|
|
|
$a->foo = 'bar';
|
|
|
|
|
|
|
|
$this->services['new_factory_service'] = $instance = $a->getInstance();
|
2014-04-13 16:18:39 +01:00
|
|
|
|
|
|
|
$instance->foo = 'bar';
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
2014-09-27 17:06:30 +01:00
|
|
|
/**
|
|
|
|
* Gets the 'service_from_static_method' service.
|
|
|
|
*
|
|
|
|
* This service is shared.
|
|
|
|
* This method always returns the same instance of the service.
|
|
|
|
*
|
2016-06-28 06:50:50 +01:00
|
|
|
* @return \Bar\FooClass A Bar\FooClass instance
|
2014-09-27 17:06:30 +01:00
|
|
|
*/
|
|
|
|
protected function getServiceFromStaticMethodService()
|
|
|
|
{
|
|
|
|
return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance();
|
|
|
|
}
|
|
|
|
|
2013-01-05 08:50:11 +00:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getParameter($name)
|
|
|
|
{
|
2017-06-12 12:31:43 +01:00
|
|
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
|
|
|
$name = strtolower($name);
|
2013-01-05 08:50:11 +00:00
|
|
|
|
2017-06-12 12:31:43 +01:00
|
|
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
|
|
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
|
|
|
}
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
2016-08-12 19:34:27 +01:00
|
|
|
if (isset($this->loadedDynamicParameters[$name])) {
|
|
|
|
return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
|
|
|
|
}
|
2013-01-05 08:50:11 +00:00
|
|
|
|
2014-12-03 08:59:38 +00:00
|
|
|
return $this->parameters[$name];
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function hasParameter($name)
|
|
|
|
{
|
2013-01-13 19:19:05 +00:00
|
|
|
$name = strtolower($name);
|
|
|
|
|
2017-06-12 12:31:43 +01:00
|
|
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function setParameter($name, $value)
|
|
|
|
{
|
2013-01-05 15:29:42 +00:00
|
|
|
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-15 06:57:34 +01:00
|
|
|
* {@inheritdoc}
|
2013-01-05 08:50:11 +00:00
|
|
|
*/
|
|
|
|
public function getParameterBag()
|
|
|
|
{
|
|
|
|
if (null === $this->parameterBag) {
|
2016-08-12 19:34:27 +01:00
|
|
|
$parameters = $this->parameters;
|
|
|
|
foreach ($this->loadedDynamicParameters as $name => $loaded) {
|
|
|
|
$parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
|
|
|
|
}
|
|
|
|
$this->parameterBag = new FrozenParameterBag($parameters);
|
2013-01-05 08:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->parameterBag;
|
|
|
|
}
|
2014-12-12 16:21:40 +00:00
|
|
|
|
2016-08-12 19:34:27 +01:00
|
|
|
private $loadedDynamicParameters = array();
|
|
|
|
private $dynamicParameters = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes a dynamic parameter.
|
|
|
|
*
|
|
|
|
* @param string The name of the dynamic parameter to load
|
|
|
|
*
|
|
|
|
* @return mixed The value of the dynamic parameter
|
|
|
|
*
|
|
|
|
* @throws InvalidArgumentException When the dynamic parameter does not exist
|
|
|
|
*/
|
|
|
|
private function getDynamicParameter($name)
|
|
|
|
{
|
|
|
|
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
|
|
|
}
|
|
|
|
|
2013-01-05 08:50:11 +00:00
|
|
|
/**
|
|
|
|
* Gets the default parameters.
|
|
|
|
*
|
|
|
|
* @return array An array of the default parameters
|
|
|
|
*/
|
|
|
|
protected function getDefaultParameters()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'baz_class' => 'BazClass',
|
2013-12-18 17:52:54 +00:00
|
|
|
'foo_class' => 'Bar\\FooClass',
|
2013-01-05 08:50:11 +00:00
|
|
|
'foo' => 'bar',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|