services26.php 4.4 KB

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