e0a0c49542b4d4798bb773f7041f50dcc366df9b
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Fixtures / php / services10.php
1 <?php
2
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;
9
10 /**
11  * ProjectServiceContainer.
12  *
13  * This class has been auto-generated
14  * by the Symfony Dependency Injection Component.
15  */
16 class ProjectServiceContainer extends Container
17 {
18     private $parameters;
19     private $targetDirs = array();
20
21     /**
22      * Constructor.
23      */
24     public function __construct()
25     {
26         $this->parameters = $this->getDefaultParameters();
27
28         $this->services = array();
29         $this->methodMap = array(
30             'test' => 'getTestService',
31         );
32
33         $this->aliases = array();
34     }
35
36     /**
37      * {@inheritdoc}
38      */
39     public function compile()
40     {
41         throw new LogicException('You cannot compile a dumped frozen container.');
42     }
43
44     /**
45      * {@inheritdoc}
46      */
47     public function isFrozen()
48     {
49         return true;
50     }
51
52     /**
53      * Gets the public 'test' shared service.
54      *
55      * @return \stdClass
56      */
57     protected function getTestService()
58     {
59         return $this->services['test'] = new \stdClass(array('only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end'));
60     }
61
62     /**
63      * {@inheritdoc}
64      */
65     public function getParameter($name)
66     {
67         $name = strtolower($name);
68
69         if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]))) {
70             throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
71         }
72         if (isset($this->loadedDynamicParameters[$name])) {
73             return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
74         }
75
76         return $this->parameters[$name];
77     }
78
79     /**
80      * {@inheritdoc}
81      */
82     public function hasParameter($name)
83     {
84         $name = strtolower($name);
85
86         return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]);
87     }
88
89     /**
90      * {@inheritdoc}
91      */
92     public function setParameter($name, $value)
93     {
94         throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
95     }
96
97     /**
98      * {@inheritdoc}
99      */
100     public function getParameterBag()
101     {
102         if (null === $this->parameterBag) {
103             $parameters = $this->parameters;
104             foreach ($this->loadedDynamicParameters as $name => $loaded) {
105                 $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
106             }
107             $this->parameterBag = new FrozenParameterBag($parameters);
108         }
109
110         return $this->parameterBag;
111     }
112
113     private $loadedDynamicParameters = array();
114     private $dynamicParameters = array();
115
116     /**
117      * Computes a dynamic parameter.
118      *
119      * @param string The name of the dynamic parameter to load
120      *
121      * @return mixed The value of the dynamic parameter
122      *
123      * @throws InvalidArgumentException When the dynamic parameter does not exist
124      */
125     private function getDynamicParameter($name)
126     {
127         throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
128     }
129
130     /**
131      * Gets the default parameters.
132      *
133      * @return array An array of the default parameters
134      */
135     protected function getDefaultParameters()
136     {
137         return array(
138             'empty_value' => '',
139             'some_string' => '-',
140         );
141     }
142 }