Passed
Push — master ( ca367b...309dd5 )
by Damien
03:01
created

DoctrineAuditRoutingLoader::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
declare(strict_types=1);
4
5
namespace DH\DoctrineAuditBundle\Routing;
6
7
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
8
use Symfony\Component\Config\Loader\Loader;
9
use Symfony\Component\Config\Loader\LoaderInterface;
10
use Symfony\Component\Routing\RouteCollection;
11
12
class DoctrineAuditRoutingLoader extends Loader implements LoaderInterface
13
{
14
    private $annotationLoader;
15
16
    private $configuration;
17
18
    public function load($resource, ?string $type = null): RouteCollection
19
    {
20
        $routeCollection = new RouteCollection();
21
        if (true === $this->configuration['enabled_viewer']) {
22
            $routeCollection = $this->annotationLoader->load('DH\DoctrineAuditBundle\Controller\AuditController');
23
        }
24
25
        return $routeCollection;
26
    }
27
28
    public function supports($resource, ?string $type = null): bool
29
    {
30
        return 'audit_loader' === $type;
31
    }
32
33
    public function setRoutingLoaderAnnotation(AnnotatedRouteControllerLoader $loader): void
34
    {
35
        $this->annotationLoader = $loader;
36
    }
37
38
    public function setConfiguration(iterable $configuration): void
39
    {
40
        $this->configuration = $configuration;
41
    }
42
}
43