services12.php 4.6 KB

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