services10.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 \stdClass
  54. */
  55. protected function getTestService()
  56. {
  57. 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', 'new line' => 'string with '."\n".'new line'));
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function getParameter($name)
  63. {
  64. $name = strtolower($name);
  65. if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]))) {
  66. throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
  67. }
  68. if (isset($this->loadedDynamicParameters[$name])) {
  69. return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
  70. }
  71. return $this->parameters[$name];
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function hasParameter($name)
  77. {
  78. $name = strtolower($name);
  79. return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters) || isset($this->loadedDynamicParameters[$name]);
  80. }
  81. /**
  82. * {@inheritdoc}
  83. */
  84. public function setParameter($name, $value)
  85. {
  86. throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
  87. }
  88. /**
  89. * {@inheritdoc}
  90. */
  91. public function getParameterBag()
  92. {
  93. if (null === $this->parameterBag) {
  94. $parameters = $this->parameters;
  95. foreach ($this->loadedDynamicParameters as $name => $loaded) {
  96. $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
  97. }
  98. $this->parameterBag = new FrozenParameterBag($parameters);
  99. }
  100. return $this->parameterBag;
  101. }
  102. private $loadedDynamicParameters = array();
  103. private $dynamicParameters = array();
  104. /**
  105. * Computes a dynamic parameter.
  106. *
  107. * @param string The name of the dynamic parameter to load
  108. *
  109. * @return mixed The value of the dynamic parameter
  110. *
  111. * @throws InvalidArgumentException When the dynamic parameter does not exist
  112. */
  113. private function getDynamicParameter($name)
  114. {
  115. throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
  116. }
  117. /**
  118. * Gets the default parameters.
  119. *
  120. * @return array An array of the default parameters
  121. */
  122. protected function getDefaultParameters()
  123. {
  124. return array(
  125. 'empty_value' => '',
  126. 'some_string' => '-',
  127. );
  128. }
  129. }