|
| 1 | +<?php |
| 2 | + |
| 3 | +use Symfony\Component\DependencyInjection\ContainerInterface; |
| 4 | +use Symfony\Component\DependencyInjection\Container; |
| 5 | +use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; |
| 6 | +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
| 7 | +use Symfony\Component\DependencyInjection\Exception\LogicException; |
| 8 | +use Symfony\Component\DependencyInjection\Exception\RuntimeException; |
| 9 | +use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; |
| 10 | + |
| 11 | +/** |
| 12 | + * ProjectServiceContainerWithClosures |
| 13 | + * |
| 14 | + * This class has been auto-generated |
| 15 | + * by the Symfony Dependency Injection Component. |
| 16 | + */ |
| 17 | +class ProjectServiceContainerWithClosures extends Container |
| 18 | +{ |
| 19 | + private static $parameters = array( |
| 20 | + 'baz' => 42, |
| 21 | + ); |
| 22 | + |
| 23 | + /** |
| 24 | + * Constructor. |
| 25 | + */ |
| 26 | + public function __construct() |
| 27 | + { |
| 28 | + $this->services = |
| 29 | + $this->scopedServices = |
| 30 | + $this->scopeStacks = array(); |
| 31 | + |
| 32 | + $this->set('service_container', $this); |
| 33 | + |
| 34 | + $this->scopes = array(); |
| 35 | + $this->scopeChildren = array(); |
| 36 | + $this->methodMap = array( |
| 37 | + 'bar' => 'getBarService', |
| 38 | + 'foo' => 'getFooService', |
| 39 | + ); |
| 40 | + |
| 41 | + $this->aliases = array(); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * {@inheritdoc} |
| 46 | + */ |
| 47 | + public function compile() |
| 48 | + { |
| 49 | + throw new LogicException('You cannot compile a dumped frozen container.'); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Gets the 'bar' service. |
| 54 | + * |
| 55 | + * This service is shared. |
| 56 | + * This method always returns the same instance of the service. |
| 57 | + * |
| 58 | + * @return \stdClass A stdClass instance. |
| 59 | + */ |
| 60 | + protected function getBarService() |
| 61 | + { |
| 62 | + return $this->services['bar'] = call_user_func(function (\stdClass $foo) { |
| 63 | + $bar = clone $foo; |
| 64 | + $bar->bar = 'bar'; |
| 65 | + return $bar; |
| 66 | +}, $this->get('foo')); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Gets the 'foo' service. |
| 71 | + * |
| 72 | + * This service is shared. |
| 73 | + * This method always returns the same instance of the service. |
| 74 | + * |
| 75 | + * @return \stdClass A stdClass instance. |
| 76 | + */ |
| 77 | + protected function getFooService() |
| 78 | + { |
| 79 | + return $this->services['foo'] = call_user_func(function (\Symfony\Component\DependencyInjection\ContainerInterface $container) { |
| 80 | + $foo = new \stdClass(); |
| 81 | + $foo->foo = $container->getParameter('baz'); |
| 82 | + return $foo; |
| 83 | +}, $this); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * {@inheritdoc} |
| 88 | + */ |
| 89 | + public function getParameter($name) |
| 90 | + { |
| 91 | + $name = strtolower($name); |
| 92 | + |
| 93 | + if (!(isset(self::$parameters[$name]) || array_key_exists($name, self::$parameters))) { |
| 94 | + throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); |
| 95 | + } |
| 96 | + |
| 97 | + return self::$parameters[$name]; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * {@inheritdoc} |
| 102 | + */ |
| 103 | + public function hasParameter($name) |
| 104 | + { |
| 105 | + $name = strtolower($name); |
| 106 | + |
| 107 | + return isset(self::$parameters[$name]) || array_key_exists($name, self::$parameters); |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * {@inheritdoc} |
| 112 | + */ |
| 113 | + public function setParameter($name, $value) |
| 114 | + { |
| 115 | + throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * {@inheritdoc} |
| 120 | + */ |
| 121 | + public function getParameterBag() |
| 122 | + { |
| 123 | + if (null === $this->parameterBag) { |
| 124 | + $this->parameterBag = new FrozenParameterBag(self::$parameters); |
| 125 | + } |
| 126 | + |
| 127 | + return $this->parameterBag; |
| 128 | + } |
| 129 | +} |
0 commit comments