1 | <?php |
||
23 | class ConfigHandler |
||
24 | { |
||
25 | private $event; |
||
26 | private $io; |
||
27 | |||
28 | /** |
||
29 | * Whether the user has received the short notice about configuration values |
||
30 | * being able to get edited later on app/config.yml |
||
31 | * @var bool |
||
32 | */ |
||
33 | private $questionInfoShown; |
||
34 | |||
35 | const CAUTION_LINE_LENGTH = 60; |
||
36 | |||
37 | public function __construct($event) |
||
42 | |||
43 | /** |
||
44 | * Migrate the config.yml file |
||
45 | */ |
||
46 | public function build() |
||
75 | |||
76 | /** |
||
77 | * Write the node in the configuration array |
||
78 | * |
||
79 | * @param NodeInterface $node The node to write |
||
80 | * @param array $config The parsed configuration |
||
81 | * @param string $parent The name of the parent nodes |
||
82 | * @return void |
||
83 | */ |
||
84 | private function writeNode(NodeInterface $node, array &$config = array(), $parent = null) |
||
85 | { |
||
86 | if ($node->getAttribute('manual')) { |
||
87 | return; |
||
88 | } |
||
89 | |||
90 | $name = $node->getName(); |
||
91 | |||
92 | if ($parent) { |
||
|
|||
93 | $name = $parent . '.' . $name; |
||
94 | } |
||
95 | |||
96 | if (!$node instanceof ArrayNode || $node instanceof PrototypedArrayNode) { |
||
97 | if (!array_key_exists($node->getName(), $config)) { |
||
98 | $config[$node->getName()] = $this->writeNodeQuestion($node, $name); |
||
99 | } |
||
100 | } else { |
||
101 | if (!isset($config[$node->getName()]) || !is_array($config[$node->getName()])) { |
||
102 | $config[$node->getName()] = array(); |
||
103 | } |
||
104 | |||
105 | foreach ($node->getChildren() as $childNode) { |
||
106 | $this->writeNode($childNode, $config[$node->getName()], $name); |
||
107 | } |
||
108 | } |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Present a node question to the user |
||
113 | * |
||
114 | * @param NodeInterface $node The node in question |
||
115 | * @param string $name The name of the node |
||
116 | * @return mixed The new value of the node |
||
117 | */ |
||
118 | private function writeNodeQuestion($node, $name) |
||
187 | |||
188 | /** |
||
189 | * Write a warning if necessary |
||
190 | * |
||
191 | * @param VariableNode $node The node with the warning |
||
192 | */ |
||
193 | private function writeWarning($node) |
||
217 | |||
218 | /** |
||
219 | * Returns the path to the configuration file |
||
220 | * |
||
221 | * @return string |
||
222 | */ |
||
223 | 1 | public static function getConfigurationPath() |
|
227 | } |
||
228 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: