3 use Symfony\Component\DependencyInjection\ContainerInterface;
4 use Symfony\Component\DependencyInjection\Container;
5 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
6 use Symfony\Component\DependencyInjection\Exception\LogicException;
7 use Symfony\Component\DependencyInjection\Exception\RuntimeException;
8 use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
11 * ProjectServiceContainer.
13 * This class has been auto-generated
14 * by the Symfony Dependency Injection Component.
16 class ProjectServiceContainer extends Container
19 private $targetDirs = array();
24 public function __construct()
26 $this->parameters = $this->getDefaultParameters();
28 $this->services = array();
29 $this->methodMap = array(
30 'bar' => 'getBarService',
31 'baz' => 'getBazService',
32 'configured_service' => 'getConfiguredServiceService',
33 'configured_service_simple' => 'getConfiguredServiceSimpleService',
34 'decorator_service' => 'getDecoratorServiceService',
35 'decorator_service_with_name' => 'getDecoratorServiceWithNameService',
36 'deprecated_service' => 'getDeprecatedServiceService',
37 'factory_service' => 'getFactoryServiceService',
38 'factory_service_simple' => 'getFactoryServiceSimpleService',
39 'foo' => 'getFooService',
40 'foo.baz' => 'getFoo_BazService',
41 'foo_bar' => 'getFooBarService',
42 'foo_with_inline' => 'getFooWithInlineService',
43 'method_call1' => 'getMethodCall1Service',
44 'new_factory_service' => 'getNewFactoryServiceService',
45 'request' => 'getRequestService',
46 'service_from_static_method' => 'getServiceFromStaticMethodService',
48 $this->aliases = array(
49 'alias_for_alias' => 'foo',
50 'alias_for_foo' => 'foo',
51 'decorated' => 'decorator_service_with_name',
58 public function compile()
60 throw new LogicException('You cannot compile a dumped frozen container.');
66 public function isFrozen()
72 * Gets the public 'bar' shared service.
74 * @return \Bar\FooClass
76 protected function getBarService()
78 $a = $this->get('foo.baz');
80 $this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar'));
82 $a->configure($instance);
88 * Gets the public 'baz' shared service.
92 protected function getBazService()
94 $this->services['baz'] = $instance = new \Baz();
96 $instance->setFoo($this->get('foo_with_inline'));
102 * Gets the public 'configured_service' shared service.
106 protected function getConfiguredServiceService()
108 $a = new \ConfClass();
109 $a->setFoo($this->get('baz'));
111 $this->services['configured_service'] = $instance = new \stdClass();
113 $a->configureStdClass($instance);
119 * Gets the public 'configured_service_simple' shared service.
123 protected function getConfiguredServiceSimpleService()
125 $this->services['configured_service_simple'] = $instance = new \stdClass();
127 (new \ConfClass('bar'))->configureStdClass($instance);
133 * Gets the public 'decorator_service' shared service.
137 protected function getDecoratorServiceService()
139 return $this->services['decorator_service'] = new \stdClass();
143 * Gets the public 'decorator_service_with_name' shared service.
147 protected function getDecoratorServiceWithNameService()
149 return $this->services['decorator_service_with_name'] = new \stdClass();
153 * Gets the public 'deprecated_service' shared service.
157 * @deprecated The "deprecated_service" service is deprecated. You should stop using it, as it will soon be removed.
159 protected function getDeprecatedServiceService()
161 @trigger_error('The "deprecated_service" service is deprecated. You should stop using it, as it will soon be removed.', E_USER_DEPRECATED);
163 return $this->services['deprecated_service'] = new \stdClass();
167 * Gets the public 'factory_service' shared service.
171 protected function getFactoryServiceService()
173 return $this->services['factory_service'] = $this->get('foo.baz')->getInstance();
177 * Gets the public 'factory_service_simple' shared service.
181 protected function getFactoryServiceSimpleService()
183 return $this->services['factory_service_simple'] = (new \SimpleFactoryClass('foo'))->getInstance();
187 * Gets the public 'foo' shared service.
189 * @return \Bar\FooClass
191 protected function getFooService()
193 $a = $this->get('foo.baz');
195 $this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this);
197 $instance->foo = 'bar';
199 $instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar');
200 $instance->setBar($this->get('bar'));
201 $instance->initialize();
202 sc_configure($instance);
208 * Gets the public 'foo.baz' shared service.
212 protected function getFoo_BazService()
214 $this->services['foo.baz'] = $instance = \BazClass::getInstance();
216 \BazClass::configureStatic1($instance);
222 * Gets the public 'foo_bar' service.
224 * @return \Bar\FooClass
226 protected function getFooBarService()
228 return new \Bar\FooClass();
232 * Gets the public 'foo_with_inline' shared service.
236 protected function getFooWithInlineService()
240 $this->services['foo_with_inline'] = $instance = new \Foo();
243 $a->setBaz($this->get('baz'));
245 $instance->setBar($a);
251 * Gets the public 'method_call1' shared service.
253 * @return \Bar\FooClass
255 protected function getMethodCall1Service()
257 require_once '%path%foo.php';
259 $this->services['method_call1'] = $instance = new \Bar\FooClass();
261 $instance->setBar($this->get('foo'));
262 $instance->setBar(NULL);
263 $instance->setBar(($this->get('foo')->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
269 * Gets the public 'new_factory_service' shared service.
273 protected function getNewFactoryServiceService()
275 $a = new \FactoryClass();
278 $this->services['new_factory_service'] = $instance = $a->getInstance();
280 $instance->foo = 'bar';
286 * Gets the public 'request' shared service.
288 * @throws RuntimeException always since this service is expected to be injected dynamically
290 protected function getRequestService()
292 throw new RuntimeException('You have requested a synthetic service ("request"). The DIC does not know how to construct this service.');
296 * Gets the public 'service_from_static_method' shared service.
298 * @return \Bar\FooClass
300 protected function getServiceFromStaticMethodService()
302 return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance();
308 public function getParameter($name)
310 $name = strtolower($name);
312 if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]))) {
313 throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
315 if (isset($this->loadedDynamicParameters[$name])) {
316 return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
319 return $this->parameters[$name];
325 public function hasParameter($name)
327 $name = strtolower($name);
329 return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]);
335 public function setParameter($name, $value)
337 throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
343 public function getParameterBag()
345 if (null === $this->parameterBag) {
346 $parameters = $this->parameters;
347 foreach ($this->loadedDynamicParameters as $name => $loaded) {
348 $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
350 $this->parameterBag = new FrozenParameterBag($parameters);
353 return $this->parameterBag;
356 private $loadedDynamicParameters = array();
357 private $dynamicParameters = array();
360 * Computes a dynamic parameter.
362 * @param string The name of the dynamic parameter to load
364 * @return mixed The value of the dynamic parameter
366 * @throws InvalidArgumentException When the dynamic parameter does not exist
368 private function getDynamicParameter($name)
370 throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
374 * Gets the default parameters.
376 * @return array An array of the default parameters
378 protected function getDefaultParameters()
381 'baz_class' => 'BazClass',
382 'foo_class' => 'Bar\\FooClass',