1 | <?php |
||
9 | class ActiveChecker |
||
10 | { |
||
11 | /** |
||
12 | * The request instance. |
||
13 | * |
||
14 | * @var Request |
||
15 | */ |
||
16 | private $request; |
||
17 | |||
18 | /** |
||
19 | * The url generator instance. |
||
20 | * |
||
21 | * @var UrlGenerator |
||
22 | */ |
||
23 | private $url; |
||
24 | |||
25 | /** |
||
26 | * Map between menu item properties and their respective test method. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | private $tests; |
||
31 | |||
32 | /** |
||
33 | * Constructor. |
||
34 | * |
||
35 | * @param Request $request |
||
36 | * @param UrlGenerator $url |
||
37 | */ |
||
38 | 61 | public function __construct(Request $request, UrlGenerator $url) |
|
53 | |||
54 | /** |
||
55 | * Checks if a menu item is currently active. Active items will be |
||
56 | * highlighted. |
||
57 | * |
||
58 | * @param mixed $item The menu item to check |
||
59 | * @return bool |
||
60 | */ |
||
61 | 60 | public function isActive($item) |
|
75 | |||
76 | /** |
||
77 | * Checks if an array of items contains an active item. |
||
78 | * |
||
79 | * @param array $items The items to check |
||
80 | * @return bool |
||
81 | */ |
||
82 | 16 | protected function containsActive($items) |
|
92 | |||
93 | /** |
||
94 | * Checks if an item is active by explicit definition of 'active' state. |
||
95 | * |
||
96 | * @param bool|array $activeDef |
||
97 | * @return bool |
||
98 | */ |
||
99 | 20 | protected function isExplicitActive($activeDef) |
|
118 | |||
119 | /** |
||
120 | * Checks if an url pattern matches the requested url. |
||
121 | * |
||
122 | * @param string $pattern |
||
123 | * @return bool |
||
124 | */ |
||
125 | 59 | protected function checkPattern($pattern) |
|
140 | } |
||
141 |