File tree 4 files changed +31
-2
lines changed
4 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 31
31
<argument type =" service" id =" knp_menu.renderer_provider" />
32
32
<argument type =" service" id =" knp_menu.menu_provider" />
33
33
<argument type =" service" id =" knp_menu.manipulator" />
34
+ <argument type =" service" id =" knp_menu.matcher" />
34
35
</service >
35
36
36
37
<service id =" knp_menu.matcher" class =" %knp_menu.matcher.class%" />
Original file line number Diff line number Diff line change @@ -105,6 +105,18 @@ public function isAncestor(ItemInterface $item, $depth = null)
105
105
return $ this ->matcher ->isAncestor ($ item , $ depth );
106
106
}
107
107
108
+ /**
109
+ * Returns the current item of a menu.
110
+ *
111
+ * @param ItemInterface|array|string $menu
112
+ *
113
+ * @return ItemInterface|null
114
+ */
115
+ public function getCurrentItem ($ menu )
116
+ {
117
+ return $ this ->helper ->getCurrentItem ($ menu );
118
+ }
119
+
108
120
/**
109
121
* @return string
110
122
*/
Original file line number Diff line number Diff line change @@ -124,6 +124,22 @@ public function testIsAncestor()
124
124
$ this ->assertFalse ($ helper ->isAncestor ($ menu ));
125
125
}
126
126
127
+ public function testGetCurrentItem ()
128
+ {
129
+ $ menu = $ this ->getMock ('Knp\Menu\ItemInterface ' );
130
+
131
+ $ helperMock = $ this ->getHelperMock (array ('getCurrentItem ' ));
132
+ $ helperMock ->expects ($ this ->any ())
133
+ ->method ('getCurrentItem ' )
134
+ ->with ('default ' )
135
+ ->will ($ this ->returnValue ($ menu ))
136
+ ;
137
+
138
+ $ helper = new MenuHelper ($ helperMock , $ this ->getMatcherMock (), $ this ->getManipulatorMock ());
139
+
140
+ $ this ->assertEquals ($ menu , $ helper ->getCurrentItem ('default ' ));
141
+ }
142
+
127
143
private function getHelperMock (array $ methods = array ())
128
144
{
129
145
return $ this ->getMockBuilder ('Knp\Menu\Twig\Helper ' )
Original file line number Diff line number Diff line change 19
19
}
20
20
],
21
21
"require" : {
22
- "knplabs/knp-menu" : " ~2.1 " ,
22
+ "knplabs/knp-menu" : " ~2.2 " ,
23
23
"symfony/framework-bundle" : " ~2.3|~3.0"
24
24
},
25
25
"require-dev" : {
31
31
},
32
32
"extra" : {
33
33
"branch-alias" : {
34
- "dev-master" : " 2.1 .x-dev"
34
+ "dev-master" : " 2.2 .x-dev"
35
35
}
36
36
}
37
37
}
You can’t perform that action at this time.
0 commit comments