|
| 1 | +<?php |
| 2 | + |
| 3 | +use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; |
| 4 | +use Symfony\Component\DependencyInjection\ContainerInterface; |
| 5 | +use Symfony\Component\DependencyInjection\Container; |
| 6 | +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
| 7 | +use Symfony\Component\DependencyInjection\Exception\LogicException; |
| 8 | +use Symfony\Component\DependencyInjection\Exception\RuntimeException; |
| 9 | +use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; |
| 10 | + |
| 11 | +/** |
| 12 | + * This class has been auto-generated |
| 13 | + * by the Symfony Dependency Injection Component. |
| 14 | + * |
| 15 | + * @final since Symfony 3.3 |
| 16 | + */ |
| 17 | +class Symfony_DI_PhpDumper_Test_CsvParameters extends Container |
| 18 | +{ |
| 19 | + private $parameters; |
| 20 | + private $targetDirs = array(); |
| 21 | + |
| 22 | + /** |
| 23 | + * @internal but protected for BC on cache:clear |
| 24 | + */ |
| 25 | + protected $privates = array(); |
| 26 | + |
| 27 | + public function __construct() |
| 28 | + { |
| 29 | + $this->parameters = $this->getDefaultParameters(); |
| 30 | + |
| 31 | + $this->services = $this->privates = array(); |
| 32 | + |
| 33 | + $this->aliases = array(); |
| 34 | + } |
| 35 | + |
| 36 | + public function reset() |
| 37 | + { |
| 38 | + $this->privates = array(); |
| 39 | + parent::reset(); |
| 40 | + } |
| 41 | + |
| 42 | + public function compile() |
| 43 | + { |
| 44 | + throw new LogicException('You cannot compile a dumped container that was already compiled.'); |
| 45 | + } |
| 46 | + |
| 47 | + public function isCompiled() |
| 48 | + { |
| 49 | + return true; |
| 50 | + } |
| 51 | + |
| 52 | + public function getRemovedIds() |
| 53 | + { |
| 54 | + return array( |
| 55 | + 'Psr\\Container\\ContainerInterface' => true, |
| 56 | + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, |
| 57 | + ); |
| 58 | + } |
| 59 | + |
| 60 | + public function getParameter($name) |
| 61 | + { |
| 62 | + $name = (string) $name; |
| 63 | + |
| 64 | + if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { |
| 65 | + throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); |
| 66 | + } |
| 67 | + if (isset($this->loadedDynamicParameters[$name])) { |
| 68 | + return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name); |
| 69 | + } |
| 70 | + |
| 71 | + return $this->parameters[$name]; |
| 72 | + } |
| 73 | + |
| 74 | + public function hasParameter($name) |
| 75 | + { |
| 76 | + $name = (string) $name; |
| 77 | + |
| 78 | + return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); |
| 79 | + } |
| 80 | + |
| 81 | + public function setParameter($name, $value) |
| 82 | + { |
| 83 | + throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); |
| 84 | + } |
| 85 | + |
| 86 | + public function getParameterBag() |
| 87 | + { |
| 88 | + if (null === $this->parameterBag) { |
| 89 | + $parameters = $this->parameters; |
| 90 | + foreach ($this->loadedDynamicParameters as $name => $loaded) { |
| 91 | + $parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name); |
| 92 | + } |
| 93 | + $this->parameterBag = new FrozenParameterBag($parameters); |
| 94 | + } |
| 95 | + |
| 96 | + return $this->parameterBag; |
| 97 | + } |
| 98 | + |
| 99 | + private $loadedDynamicParameters = array( |
| 100 | + 'hello' => false, |
| 101 | + ); |
| 102 | + private $dynamicParameters = array(); |
| 103 | + |
| 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 | + switch ($name) { |
| 116 | + case 'hello': $value = $this->getEnv('csv:foo'); break; |
| 117 | + default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name)); |
| 118 | + } |
| 119 | + $this->loadedDynamicParameters[$name] = true; |
| 120 | + |
| 121 | + return $this->dynamicParameters[$name] = $value; |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Gets the default parameters. |
| 126 | + * |
| 127 | + * @return array An array of the default parameters |
| 128 | + */ |
| 129 | + protected function getDefaultParameters() |
| 130 | + { |
| 131 | + return array( |
| 132 | + 'env(foo)' => 'foo,bar', |
| 133 | + ); |
| 134 | + } |
| 135 | +} |
0 commit comments