services_array_params.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
  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. * This class has been auto-generated
  11. * by the Symfony Dependency Injection Component.
  12. *
  13. * @final since Symfony 3.3
  14. */
  15. class ProjectServiceContainer extends Container
  16. {
  17. private $parameters;
  18. private $targetDirs = array();
  19. public function __construct()
  20. {
  21. $dir = __DIR__;
  22. for ($i = 1; $i <= 5; ++$i) {
  23. $this->targetDirs[$i] = $dir = \dirname($dir);
  24. }
  25. $this->parameters = $this->getDefaultParameters();
  26. $this->services = array();
  27. $this->methodMap = array(
  28. 'bar' => 'getBarService',
  29. );
  30. $this->aliases = array();
  31. }
  32. public function getRemovedIds()
  33. {
  34. return array(
  35. 'Psr\\Container\\ContainerInterface' => true,
  36. 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
  37. );
  38. }
  39. public function compile()
  40. {
  41. throw new LogicException('You cannot compile a dumped container that was already compiled.');
  42. }
  43. public function isCompiled()
  44. {
  45. return true;
  46. }
  47. public function isFrozen()
  48. {
  49. @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the isCompiled() method instead.', __METHOD__), E_USER_DEPRECATED);
  50. return true;
  51. }
  52. /**
  53. * Gets the public 'bar' shared service.
  54. *
  55. * @return \BarClass
  56. */
  57. protected function getBarService()
  58. {
  59. $this->services['bar'] = $instance = new \BarClass();
  60. $instance->setBaz($this->parameters['array_1'], $this->getParameter('array_2'), '%array_1%', $this->parameters['array_1']);
  61. return $instance;
  62. }
  63. public function getParameter($name)
  64. {
  65. $name = (string) $name;
  66. if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
  67. $name = $this->normalizeParameterName($name);
  68. if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
  69. throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
  70. }
  71. }
  72. if (isset($this->loadedDynamicParameters[$name])) {
  73. return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
  74. }
  75. return $this->parameters[$name];
  76. }
  77. public function hasParameter($name)
  78. {
  79. $name = (string) $name;
  80. $name = $this->normalizeParameterName($name);
  81. return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
  82. }
  83. public function setParameter($name, $value)
  84. {
  85. throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
  86. }
  87. public function getParameterBag()
  88. {
  89. if (null === $this->parameterBag) {
  90. $parameters = $this->parameters;
  91. foreach ($this->loadedDynamicParameters as $name => $loaded) {
  92. $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
  93. }
  94. $this->parameterBag = new FrozenParameterBag($parameters);
  95. }
  96. return $this->parameterBag;
  97. }
  98. private $loadedDynamicParameters = array(
  99. 'array_2' => false,
  100. );
  101. private $dynamicParameters = array();
  102. /**
  103. * Computes a dynamic parameter.
  104. *
  105. * @param string The name of the dynamic parameter to load
  106. *
  107. * @return mixed The value of the dynamic parameter
  108. *
  109. * @throws InvalidArgumentException When the dynamic parameter does not exist
  110. */
  111. private function getDynamicParameter($name)
  112. {
  113. switch ($name) {
  114. case 'array_2': $value = array(
  115. 0 => ($this->targetDirs[2].'/Dumper'),
  116. ); break;
  117. default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
  118. }
  119. $this->loadedDynamicParameters[$name] = true;
  120. return $this->dynamicParameters[$name] = $value;
  121. }
  122. private $normalizedParameterNames = array();
  123. private function normalizeParameterName($name)
  124. {
  125. if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
  126. $normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
  127. if ((string) $name !== $normalizedName) {
  128. @trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since Symfony 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
  129. }
  130. } else {
  131. $normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
  132. }
  133. return $normalizedName;
  134. }
  135. /**
  136. * Gets the default parameters.
  137. *
  138. * @return array An array of the default parameters
  139. */
  140. protected function getDefaultParameters()
  141. {
  142. return array(
  143. 'array_1' => array(
  144. 0 => 123,
  145. ),
  146. );
  147. }
  148. }