1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * (c) Christian Gripp <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Core23\Twig\Bridge\Symfony\DependencyInjection; |
||
13 | |||
14 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||
15 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||
16 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||
17 | |||
18 | final class Configuration implements ConfigurationInterface |
||
19 | { |
||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | public function getConfigTreeBuilder() |
||
24 | { |
||
25 | $treeBuilder = new TreeBuilder('core23_twig'); |
||
26 | |||
27 | // Keep compatibility with symfony/config < 4.2 |
||
28 | if (!method_exists($treeBuilder, 'getRootNode')) { |
||
29 | $rootNode = $treeBuilder->root('core23_twig'); |
||
30 | } else { |
||
31 | $rootNode = $treeBuilder->getRootNode(); |
||
32 | } |
||
33 | \assert($rootNode instanceof ArrayNodeDefinition); |
||
34 | |||
35 | $this->addPaginationSection($rootNode); |
||
36 | |||
37 | return $treeBuilder; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param ArrayNodeDefinition $node |
||
42 | */ |
||
43 | private function addPaginationSection(ArrayNodeDefinition $node): void |
||
44 | { |
||
45 | $node |
||
46 | ->children() |
||
47 | ->arrayNode('pagination') |
||
48 | ->addDefaultsIfNotSet() |
||
49 | ->children() |
||
50 | ->scalarNode('template')->defaultValue('@Core23Twig/Pager/pagination.html.twig')->end() |
||
51 | ->scalarNode('extremeLimit')->defaultValue(3)->end() |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
52 | ->scalarNode('nearbyLimit')->defaultValue(2)->end() |
||
53 | ->end() |
||
54 | ->end() |
||
55 | ->end() |
||
56 | ; |
||
57 | } |
||
58 | } |
||
59 |