services8.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. $this->parameters = $this->getDefaultParameters();
  22. $this->services = array();
  23. $this->aliases = array();
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function compile()
  29. {
  30. throw new LogicException('You cannot compile a dumped container that was already compiled.');
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function isCompiled()
  36. {
  37. return true;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function isFrozen()
  43. {
  44. @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);
  45. return true;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function getParameter($name)
  51. {
  52. $name = strtolower($name);
  53. if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]))) {
  54. throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
  55. }
  56. if (isset($this->loadedDynamicParameters[$name])) {
  57. return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
  58. }
  59. return $this->parameters[$name];
  60. }
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function hasParameter($name)
  65. {
  66. $name = strtolower($name);
  67. return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]);
  68. }
  69. /**
  70. * {@inheritdoc}
  71. */
  72. public function setParameter($name, $value)
  73. {
  74. throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
  75. }
  76. /**
  77. * {@inheritdoc}
  78. */
  79. public function getParameterBag()
  80. {
  81. if (null === $this->parameterBag) {
  82. $parameters = $this->parameters;
  83. foreach ($this->loadedDynamicParameters as $name => $loaded) {
  84. $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
  85. }
  86. $this->parameterBag = new FrozenParameterBag($parameters);
  87. }
  88. return $this->parameterBag;
  89. }
  90. private $loadedDynamicParameters = array();
  91. private $dynamicParameters = array();
  92. /**
  93. * Computes a dynamic parameter.
  94. *
  95. * @param string The name of the dynamic parameter to load
  96. *
  97. * @return mixed The value of the dynamic parameter
  98. *
  99. * @throws InvalidArgumentException When the dynamic parameter does not exist
  100. */
  101. private function getDynamicParameter($name)
  102. {
  103. throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
  104. }
  105. /**
  106. * Gets the default parameters.
  107. *
  108. * @return array An array of the default parameters
  109. */
  110. protected function getDefaultParameters()
  111. {
  112. return array(
  113. 'foo' => 'bar',
  114. 'baz' => 'bar',
  115. 'bar' => 'foo is %foo bar',
  116. 'escape' => '@escapeme',
  117. 'values' => array(
  118. 0 => true,
  119. 1 => false,
  120. 2 => NULL,
  121. 3 => 0,
  122. 4 => 1000.3,
  123. 5 => 'true',
  124. 6 => 'false',
  125. 7 => 'null',
  126. ),
  127. );
  128. }
  129. }