|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the `tvi/monitor-bundle` project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) https://github.com/turnaev/monitor-bundle/graphs/contributors |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
namespace Tvi\MonitorBundle\Check; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
|
15
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
16
|
|
|
use Tvi\MonitorBundle\Exception\FeatureRequired; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
|
|
|
|
|
19
|
|
|
* @author Vladimir Turnaev <[email protected]> |
|
20
|
|
|
*/ |
|
|
|
|
|
|
21
|
|
|
abstract class CheckPluginAbstract implements CheckPluginInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
|
|
|
|
|
24
|
|
|
* @throws FeatureRequired |
|
25
|
|
|
*/ |
|
|
|
|
|
|
26
|
32 |
|
public function checkRequirements() |
|
27
|
|
|
{ |
|
28
|
32 |
|
} |
|
29
|
|
|
|
|
30
|
45 |
|
public function checkConf(TreeBuilder $builder): NodeDefinition |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
$node = $builder |
|
33
|
45 |
|
->root(static::CHECK_NAME, 'array') |
|
34
|
45 |
|
->info(static::DESCR); //-- |
|
35
|
|
|
|
|
36
|
45 |
|
$this->_check($node); |
|
37
|
|
|
|
|
38
|
45 |
|
return $node; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
45 |
|
public function checkFactoryConf(TreeBuilder $builder): NodeDefinition |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
$node = $builder |
|
44
|
45 |
|
->root(static::CHECK_NAME.'_factory', 'array') |
|
45
|
45 |
|
->info(static::DESCR) |
|
46
|
45 |
|
->children() |
|
47
|
45 |
|
->arrayNode('items') |
|
|
|
|
|
|
48
|
45 |
|
->useAttributeAsKey('key') |
|
|
|
|
|
|
49
|
45 |
|
->prototype('array'); //-- |
|
|
|
|
|
|
50
|
45 |
|
$node = $this->_check($node) |
|
51
|
45 |
|
->end() |
|
|
|
|
|
|
52
|
45 |
|
->/* @scrutinizer ignore-call */ end() |
|
|
|
|
|
|
53
|
45 |
|
->end(); |
|
54
|
|
|
|
|
55
|
45 |
|
$this->_group($node); |
|
56
|
45 |
|
$this->_tags($node); |
|
57
|
45 |
|
$this->_label($node); |
|
58
|
|
|
|
|
59
|
45 |
|
return $node; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
abstract protected function _check(NodeDefinition $node): NodeDefinition; |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
45 |
|
protected function _label(NodeDefinition $node): NodeDefinition |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
return $node |
|
67
|
45 |
|
->children() |
|
68
|
45 |
|
->scalarNode('label')->defaultNull()->end() |
|
|
|
|
|
|
69
|
45 |
|
->end(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
45 |
|
protected function _group(NodeDefinition $node): NodeDefinition |
|
|
|
|
|
|
73
|
|
|
{ |
|
74
|
|
|
return $node |
|
75
|
45 |
|
->children() |
|
76
|
45 |
|
->scalarNode('group') |
|
|
|
|
|
|
77
|
45 |
|
->defaultValue(static::GROUP) |
|
|
|
|
|
|
78
|
45 |
|
->cannotBeEmpty() |
|
|
|
|
|
|
79
|
45 |
|
->end() |
|
|
|
|
|
|
80
|
45 |
|
->end(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
45 |
|
protected function _tags(NodeDefinition $node): NodeDefinition |
|
|
|
|
|
|
84
|
|
|
{ |
|
85
|
|
|
return $node |
|
86
|
45 |
|
->children() |
|
87
|
45 |
|
->arrayNode('tags') |
|
|
|
|
|
|
88
|
45 |
|
->prototype('scalar')->end() |
|
|
|
|
|
|
89
|
45 |
|
->end() |
|
|
|
|
|
|
90
|
45 |
|
->end(); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|