Skip to content

Commit 9994ef0

Browse files
committed
future-proof compatibility with symfony 4.2+
1 parent c6e764b commit 9994ef0

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,32 @@
1212
*/
1313
class Configuration implements ConfigurationInterface
1414
{
15+
/** @var string */
16+
protected $alias;
17+
18+
public function __construct($alias = 'gate_keeper')
19+
{
20+
$this->alias = $alias;
21+
}
22+
1523
/**
1624
* {@inheritDoc}
1725
*/
1826
public function getConfigTreeBuilder()
1927
{
20-
$treeBuilder = new TreeBuilder();
21-
/** @noinspection PhpUndefinedMethodInspection */
22-
$treeBuilder->root('gate_keeper')
28+
$treeBuilder = new TreeBuilder($this->alias);
29+
30+
$rootNode = method_exists($treeBuilder, 'getRootNode') ?
31+
$treeBuilder->getRootNode()
32+
:
33+
$treeBuilder->root($this->alias); // BC layer for symfony/config 4.1 and older
34+
35+
$rootNode
2336
->children()
2437
->scalarNode('repository_service')
2538
->defaultValue('gatekeeper.repository.dummy')
2639
->end()
27-
->scalarNode('provider_service')
40+
->scalarNode('provider_service')
2841
->defaultValue('gatekeeper.gates_provider.dummy')
2942
->end()
3043
->end();

0 commit comments

Comments
 (0)