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 | * Constructor. |
||
27 | * |
||
28 | * @param Request $request |
||
29 | * @param UrlGenerator $url |
||
30 | */ |
||
31 | 56 | public function __construct(Request $request, UrlGenerator $url) |
|
36 | |||
37 | /** |
||
38 | * Checks if a menu item is currently active. Active items will be |
||
39 | * highlighted. |
||
40 | * |
||
41 | * @param mixed $item The menu item to check |
||
42 | * @return bool |
||
43 | */ |
||
44 | 55 | public function isActive($item) |
|
59 | |||
60 | /** |
||
61 | * Checks if an array of items contains an active item. |
||
62 | * |
||
63 | * @param array $items The items to check |
||
64 | * @return bool |
||
65 | */ |
||
66 | 18 | protected function containsActive($items) |
|
76 | |||
77 | /** |
||
78 | * Checks if an item is active by explicit definition of 'active' state. |
||
79 | * |
||
80 | * @param bool|array $activeDef |
||
81 | * @return bool |
||
82 | */ |
||
83 | 19 | protected function isExplicitActive($activeDef) |
|
102 | |||
103 | /** |
||
104 | * Checks if an url pattern matches the requested url. |
||
105 | * |
||
106 | * @param string $pattern |
||
107 | * @return bool |
||
108 | */ |
||
109 | 51 | protected function checkPattern($pattern) |
|
123 | } |
||
124 |