1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
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 Sonata\SeoBundle\DependencyInjection; |
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
|
|
|
/** |
21
|
|
|
* This is the class that validates and merges configuration from your app/config files. |
22
|
|
|
*/ |
23
|
|
|
class Configuration implements ConfigurationInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
|
|
public function getConfigTreeBuilder() |
29
|
|
|
{ |
30
|
|
|
$treeBuilder = new TreeBuilder('sonata_seo'); |
31
|
|
|
|
32
|
|
|
// Keep compatibility with symfony/config < 4.2 |
33
|
|
|
if (!method_exists($treeBuilder, 'getRootNode')) { |
34
|
|
|
$rootNode = $treeBuilder->root('sonata_seo'); |
|
|
|
|
35
|
|
|
} else { |
36
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$rootNode |
40
|
|
|
->children() |
41
|
|
|
->scalarNode('encoding')->defaultValue('UTF-8')->end() |
42
|
|
|
->arrayNode('page') |
43
|
|
|
->addDefaultsIfNotSet() |
44
|
|
|
->children() |
45
|
|
|
->scalarNode('default')->defaultValue('sonata.seo.page.default')->end() |
46
|
|
|
->arrayNode('head') |
47
|
|
|
->normalizeKeys(false) |
48
|
|
|
->useAttributeAsKey('attribute') |
49
|
|
|
->prototype('scalar')->end() |
50
|
|
|
->end() |
51
|
|
|
->arrayNode('metas') |
52
|
|
|
->normalizeKeys(false) |
53
|
|
|
->useAttributeAsKey('element') |
54
|
|
|
->prototype('array') |
55
|
|
|
->normalizeKeys(false) |
56
|
|
|
->useAttributeAsKey('name') |
57
|
|
|
->prototype('scalar')->end() |
58
|
|
|
->end() |
59
|
|
|
->end() |
60
|
|
|
->scalarNode('separator')->defaultValue(' - ')->end() |
61
|
|
|
// NEXT_MAJOR: Make this field required |
62
|
|
|
->scalarNode('title')->defaultValue('Project name')->end() |
63
|
|
|
->end() |
64
|
|
|
->end() |
65
|
|
|
->arrayNode('sitemap') |
66
|
|
|
->addDefaultsIfNotSet() |
67
|
|
|
->children() |
68
|
|
|
->arrayNode('doctrine_orm') |
69
|
|
|
->prototype('variable')->end() |
70
|
|
|
->end() |
71
|
|
|
->arrayNode('services') |
72
|
|
|
->prototype('variable')->end() |
73
|
|
|
->end() |
74
|
|
|
->end() |
75
|
|
|
->end() |
76
|
|
|
->end() |
77
|
|
|
; |
78
|
|
|
|
79
|
|
|
$this->addHttpClientSection($rootNode); |
|
|
|
|
80
|
|
|
|
81
|
|
|
return $treeBuilder; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
private function addHttpClientSection(ArrayNodeDefinition $node): void |
85
|
|
|
{ |
86
|
|
|
$node |
87
|
|
|
->children() |
88
|
|
|
->arrayNode('http') |
89
|
|
|
->addDefaultsIfNotSet() |
90
|
|
|
->children() |
91
|
|
|
->scalarNode('client') |
92
|
|
|
->defaultNull() |
93
|
|
|
->info('Alias of the http client.') |
94
|
|
|
->end() |
95
|
|
|
->scalarNode('message_factory') |
96
|
|
|
->defaultNull() |
97
|
|
|
->info('Alias of the message factory.') |
98
|
|
|
->end() |
99
|
|
|
->end() |
100
|
|
|
->end() |
101
|
|
|
->end(); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.