Passed
Push — master ( 22b3c3...f1c87c )
by Damien
02:37
created

RoutingAnnotationLoader::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace DH\DoctrineAuditBundle\Routing;
4
5
use DH\DoctrineAuditBundle\Controller\ViewerController;
6
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
7
use Symfony\Component\Config\Loader\Loader;
8
use Symfony\Component\Routing\RouteCollection;
9
10
class RoutingAnnotationLoader extends Loader
11
{
12
    /**
13
     * @var AnnotatedRouteControllerLoader
14
     */
15
    private $annotatedRouteControllerLoader;
16
17
    /**
18
     * @var array
19
     */
20
    private $configuration;
21
22
    public function load($resource, ?string $type = null): RouteCollection
23
    {
24
        $routeCollection = new RouteCollection();
25
        if (true === $this->configuration['enabled_viewer']) {
26
            $routeCollection = $this->annotatedRouteControllerLoader->load(ViewerController::class);
27
        }
28
29
        return $routeCollection;
30
    }
31
32
    public function supports($resource, ?string $type = null): bool
33
    {
34
        return 'annotation' === $type;
35
    }
36
37
    public function setAnnotatedRouteControllerLoader(AnnotatedRouteControllerLoader $annotatedRouteController): void
38
    {
39
        $this->annotatedRouteControllerLoader = $annotatedRouteController;
40
    }
41
42
    public function setConfiguration(array $configuration): void
43
    {
44
        $this->configuration = $configuration;
45
    }
46
}
47