1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Sendy\SendyBundle\DependencyInjection; |
||
6 | |||
7 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||
8 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||
9 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||
10 | |||
11 | final class Configuration implements ConfigurationInterface |
||
12 | { |
||
13 | public function getConfigTreeBuilder(): TreeBuilder |
||
14 | { |
||
15 | $treeBuilder = new TreeBuilder('sendy'); |
||
16 | |||
17 | $rootNode = $treeBuilder->getRootNode(); |
||
18 | $this->addSendySection($rootNode); |
||
19 | |||
20 | return $treeBuilder; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Parses the "sendy" block config section |
||
25 | * Example for yaml section: |
||
26 | * sendy: |
||
27 | * api_key: "yourapiKEYHERE" |
||
28 | * api_host: "https://updates.mydomain.com" |
||
29 | * list_id: "your_list_id_goes_here". |
||
30 | */ |
||
31 | private function addSendySection(ArrayNodeDefinition $node): void |
||
32 | { |
||
33 | $node |
||
34 | ->children() |
||
35 | ->scalarNode('api_key') |
||
36 | ->isRequired() |
||
37 | ->cannotBeEmpty() |
||
38 | ->end() |
||
39 | ->scalarNode('api_host') |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
40 | ->isRequired() |
||
41 | ->cannotBeEmpty() |
||
42 | ->end() |
||
43 | ->scalarNode('list_id') |
||
44 | ->isRequired() |
||
45 | ->cannotBeEmpty() |
||
46 | ->end() |
||
47 | ->end(); |
||
48 | } |
||
49 | } |
||
50 |