1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the ekino Drupal Debug project. |
7
|
|
|
* |
8
|
|
|
* (c) ekino |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Ekino\Drupal\Debug\Configuration; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
17
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
18
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
19
|
|
|
|
20
|
|
|
class Configuration implements ConfigurationInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
4 |
|
public function getConfigTreeBuilder(): TreeBuilder |
26
|
|
|
{ |
27
|
4 |
|
$treeBuilder = new TreeBuilder(); |
28
|
|
|
/** @var ArrayNodeDefinition $rootNode */ |
29
|
4 |
|
$rootNode = $treeBuilder->root('drupal-debug'); |
30
|
|
|
|
31
|
|
|
$rootNode |
32
|
4 |
|
->info('This is the drupal-debug configuration file.') |
33
|
4 |
|
->children() |
34
|
4 |
|
->append($this->getDefaultsConfigNode()) |
35
|
4 |
|
->append($this->getSubstituteOriginalDrupalKernelConfigNode()) |
36
|
4 |
|
->end(); |
37
|
|
|
|
38
|
4 |
|
return $treeBuilder; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return ArrayNodeDefinition |
43
|
|
|
*/ |
44
|
4 |
|
private function getDefaultsConfigNode(): ArrayNodeDefinition |
45
|
|
|
{ |
46
|
4 |
|
return (new ArrayNodeDefinition('defaults')) |
47
|
4 |
|
->info('The defaults values are common values that are reused by different actions.') |
48
|
4 |
|
->addDefaultsIfNotSet() |
49
|
4 |
|
->children() |
50
|
4 |
|
->scalarNode('cache_directory') |
51
|
4 |
|
->cannotBeEmpty() |
52
|
4 |
|
->defaultValue('cache') |
53
|
4 |
|
->end() |
54
|
4 |
|
->arrayNode('logger') |
|
|
|
|
55
|
4 |
|
->canBeDisabled() |
56
|
4 |
|
->children() |
57
|
4 |
|
->scalarNode('channel') |
58
|
4 |
|
->cannotBeEmpty() |
59
|
4 |
|
->defaultValue('drupal-debug') |
60
|
4 |
|
->end() |
61
|
4 |
|
->scalarNode('file_path') |
62
|
4 |
|
->cannotBeEmpty() |
63
|
4 |
|
->defaultValue('logs/drupal-debug.log') |
64
|
4 |
|
->end() |
65
|
4 |
|
->end() |
66
|
4 |
|
->end() |
67
|
4 |
|
->scalarNode('charset') |
68
|
4 |
|
->defaultNull() |
69
|
4 |
|
->end() |
70
|
4 |
|
->scalarNode('file_link_format') |
71
|
4 |
|
->defaultNull() |
72
|
4 |
|
->end() |
73
|
4 |
|
->end(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return ArrayNodeDefinition |
78
|
|
|
*/ |
79
|
4 |
|
private function getSubstituteOriginalDrupalKernelConfigNode(): ArrayNodeDefinition |
80
|
|
|
{ |
81
|
4 |
|
return (new ArrayNodeDefinition('substitute_original_drupal_kernel')) |
82
|
4 |
|
->info("It is recommended to disable the original DrupalKernel substitution to run your tests.\nTo programmatically toggle it, use the two dedicated composer commands.") |
83
|
4 |
|
->canBeDisabled() |
84
|
4 |
|
->children() |
85
|
4 |
|
->scalarNode('composer_autoload_file_path') |
86
|
4 |
|
->cannotBeEmpty() |
87
|
4 |
|
->defaultValue('vendor/autoload.php') |
88
|
4 |
|
->end() |
89
|
4 |
|
->scalarNode('cache_directory') |
|
|
|
|
90
|
4 |
|
->info('If not specified, it fall backs to the default cache directory.') |
91
|
4 |
|
->defaultNull() |
92
|
4 |
|
->end() |
93
|
4 |
|
->end(); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|