|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace RedirectionIO\Client\ProxySymfony\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
|
|
|
|
|
6
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @internal |
|
10
|
|
|
*/ |
|
11
|
|
|
final class Configuration implements ConfigurationInterface |
|
12
|
|
|
{ |
|
13
|
|
|
const ROOT_NAME = 'redirection_io'; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* {@inheritdoc} |
|
17
|
|
|
*/ |
|
18
|
|
|
public function getConfigTreeBuilder() |
|
19
|
|
|
{ |
|
20
|
|
|
$treeBuilder = new TreeBuilder(self::ROOT_NAME); |
|
21
|
|
|
$rootNode = $this->getRootNode($treeBuilder); |
|
22
|
|
|
$excludedPrefixes = ['/_wdt', '/_profiler', '/_error']; |
|
23
|
|
|
|
|
24
|
|
|
$rootNode |
|
25
|
|
|
->children() |
|
26
|
|
|
->scalarNode('project_key') |
|
27
|
|
|
->isRequired() |
|
28
|
|
|
->cannotBeEmpty() |
|
29
|
|
|
->info('Your project key that can be found at: https://redirection.io/manager/<organization>/<project>/instances') |
|
30
|
|
|
->end() |
|
31
|
|
|
->arrayNode('connections') |
|
32
|
|
|
->normalizeKeys(false) |
|
33
|
|
|
->useAttributeAsKey('name') |
|
34
|
|
|
->addDefaultChildrenIfNoneSet('default') |
|
35
|
|
|
->prototype('scalar') |
|
36
|
|
|
->info('a TCP or unix socket') |
|
37
|
|
|
->example('tcp://127.0.0.1:20301 or unix:///var/run/redirectionio_agent.sock') |
|
38
|
|
|
->isRequired() |
|
39
|
|
|
->cannotBeEmpty() |
|
40
|
|
|
->defaultValue('tcp://127.0.0.1:20301') |
|
41
|
|
|
->end() |
|
42
|
|
|
->end() |
|
43
|
|
|
->booleanNode('persist') |
|
44
|
|
|
->info('Persist client connections to be reuse on other requests') |
|
45
|
|
|
->defaultTrue() |
|
46
|
|
|
->end() |
|
47
|
|
|
->booleanNode('debug') |
|
48
|
|
|
->info('Throw exception if something wrong happens') |
|
49
|
|
|
->defaultValue('%kernel.debug%') |
|
50
|
|
|
->end() |
|
51
|
|
|
->booleanNode('match_on_response') |
|
52
|
|
|
->info('Allow match on response status rules') |
|
53
|
|
|
->defaultValue(false) |
|
54
|
|
|
->end() |
|
55
|
|
|
->arrayNode('excluded_prefixes') |
|
56
|
|
|
->info('Exclude a set of prefixes from processing') |
|
57
|
|
|
->prototype('scalar')->end() |
|
58
|
|
|
->validate() |
|
59
|
|
|
->always() |
|
60
|
|
|
->then(function ($v) use ($excludedPrefixes) { return array_unique(array_merge($excludedPrefixes, $v)); }) |
|
61
|
|
|
->end() |
|
62
|
|
|
->defaultValue($excludedPrefixes) |
|
63
|
|
|
->end() |
|
64
|
|
|
->arrayNode('excluded_hosts') |
|
65
|
|
|
->info('Exclude a set of hosts from processing') |
|
66
|
|
|
->prototype('scalar')->end() |
|
67
|
|
|
->end() |
|
68
|
|
|
->end() |
|
69
|
|
|
; |
|
70
|
|
|
|
|
71
|
|
|
return $treeBuilder; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Returns the root node of TreeBuilder with backwards compatibility with Symfony < 4.3 |
|
76
|
|
|
*/ |
|
77
|
|
|
private function getRootNode(TreeBuilder $treeBuilder): NodeDefinition |
|
|
|
|
|
|
78
|
|
|
{ |
|
79
|
|
|
if (\method_exists($treeBuilder, 'getRootNode')) { |
|
80
|
|
|
return $treeBuilder->getRootNode(); |
|
81
|
|
|
} else { |
|
82
|
|
|
return $treeBuilder->root(self::ROOT_NAME); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths