Completed
Push — ezp-31079-twig-variables ( 1c4141 )
by
unknown
14:24
created

setTwigVariableProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\MVC\Symfony\View;
10
11
use Traversable;
12
13
final class GenericVariableProviderRegistry implements VariableProviderRegistry
14
{
15
    /** @var \eZ\Publish\Core\MVC\Symfony\View\VariableProvider[] */
16
    private $twigVariableProviders;
17
18
    public function __construct(Traversable $twigVariableProviders)
19
    {
20
        foreach ($twigVariableProviders as $twigVariableProvider) {
21
            $this->setTwigVariableProvider($twigVariableProvider);
22
        }
23
    }
24
25
    public function setTwigVariableProvider(VariableProvider $twigVariableProvider): void
26
    {
27
        $this->twigVariableProviders[$twigVariableProvider->getIdentifier()] = $twigVariableProvider;
28
    }
29
30
    public function getTwigVariableProvider(string $identifier): ?VariableProvider
31
    {
32
        return $this->twigVariableProviders[$identifier] ?? null;
33
    }
34
35
    public function hasTwigVariableProvider(string $identifier): bool
36
    {
37
        return isset($this->twigVariableProviders[$identifier]);
38
    }
39
}
40