Completed
Push — 8.x-1.x ( 630823...f12348 )
by
unknown
30:40
created

Route::modifyRouteClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Drupal\controller_annotations\Configuration;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route as BaseRoute;
6
use Symfony\Component\Routing\Route as RoutingRoute;
7
8
/**
9
 * @Annotation
10
 */
11
class Route extends BaseRoute implements RouteModifierMethodInterface, RouteModifierClassInterface
12
{
13
    /**
14
     * @var bool
15
     */
16
    protected $admin;
17
18
    /**
19
     * @return bool
20
     */
21 7
    public function isAdmin()
22
    {
23 7
        return $this->admin;
24
    }
25
26
    /**
27
     * @param bool $admin
28
     * @return Route
29
     */
30 6
    public function setAdmin($admin)
31
    {
32 6
        $this->admin = $admin;
33
34 6
        return $this;
35
    }
36
37
    /**
38
     * @param RoutingRoute $route
39
     * @param \ReflectionClass $class
40
     * @param \ReflectionMethod $method
41
     */
42 6
    public function modifyRouteClass(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method)
43
    {
44 6
        $this->modifyRoute($route, $class, $method);
45 6
    }
46
47
    /**
48
     * @param RoutingRoute $route
49
     * @param \ReflectionClass $class
50
     * @param \ReflectionMethod $method
51
     */
52 6
    public function modifyRouteMethod(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method)
53
    {
54 6
        if ($this->getService()) {
55
            throw new \LogicException('The service option can only be specified at class level.');
56
        }
57
58 6
        $this->modifyRoute($route, $class, $method);
59 6
    }
60
61
    /**
62
     * @param RoutingRoute $route
63
     * @param \ReflectionClass $class
64
     * @param \ReflectionMethod $method
65
     */
66 7
    protected function modifyRoute(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
67
    {
68 7
        if ($this->isAdmin()) {
69 6
            $route->setOption('_admin_route', true);
70
        }
71 7
    }
72
}
73