| Conditions | 3 |
| Paths | 1 |
| Total Lines | 50 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 40 | public function configure(ArrayNodeDefinition $node) |
||
| 41 | { |
||
| 42 | $node |
||
| 43 | ->beforeNormalization() |
||
| 44 | ->ifString() |
||
| 45 | ->then(function ($v) { |
||
| 46 | $home = getenv('HOME'); |
||
| 47 | $filepath = $home.'/.openl10n/server.conf'; |
||
| 48 | $data = array(); |
||
| 49 | if (file_exists($filepath)) { |
||
| 50 | $data = parse_ini_file($filepath, true); |
||
| 51 | } |
||
| 52 | if (isset($data[$v])) { |
||
| 53 | return $data[$v]; |
||
| 54 | } |
||
| 55 | |||
| 56 | return array( |
||
| 57 | 'hostname' => $v |
||
| 58 | ); |
||
| 59 | }) |
||
| 60 | ->end() |
||
| 61 | ->children() |
||
| 62 | ->scalarNode('hostname') |
||
| 63 | ->isRequired() |
||
| 64 | ->cannotBeEmpty() |
||
| 65 | ->end() |
||
| 66 | ->scalarNode('username') |
||
| 67 | ->isRequired() |
||
| 68 | ->cannotBeEmpty() |
||
| 69 | ->end() |
||
| 70 | ->scalarNode('password') |
||
| 71 | ->isRequired() |
||
| 72 | ->cannotBeEmpty() |
||
| 73 | ->end() |
||
| 74 | ->booleanNode('use_ssl') |
||
| 75 | // Because data parsed from an INI file is not |
||
| 76 | // interpreted as boolean, then cast automatically. |
||
| 77 | ->beforeNormalization() |
||
| 78 | ->ifString() |
||
| 79 | ->then(function ($v) { |
||
| 80 | return (boolean) $v; |
||
| 81 | }) |
||
| 82 | ->end() |
||
| 83 | ->defaultFalse() |
||
| 84 | ->end() |
||
| 85 | ->integerNode('port') |
||
| 86 | ->defaultNull() |
||
| 87 | ->end() |
||
| 88 | ->end(); |
||
| 89 | } |
||
| 90 | |||
| 99 |