1
+ <?php
2
+ /**
3
+ * Adds methods that can be called from the actions class
4
+ *
5
+ * @package ioDoctrineMenuPlugin
6
+ * @subpackage actions
7
+ * @author Ryan Weaver <[email protected] >
8
+ */
9
+ class ioDoctrineMenuActions
10
+ {
11
+ /**
12
+ * @var ioDoctrineMenuPluginConfiguration
13
+ */
14
+ protected $ _pluginConfiguration ;
15
+
16
+ /**
17
+ * Class constructor
18
+ *
19
+ * @param ioDoctrineMenuPluginConfiguration $configuration
20
+ */
21
+ public function __construct (ioDoctrineMenuPluginConfiguration $ configuration )
22
+ {
23
+ $ this ->_pluginConfiguration = $ configuration ;
24
+ }
25
+
26
+ /**
27
+ * Returns an ioMenuItem tree loaded from the given name that corresponds
28
+ * to a root node name in the ioDoctrineMenuItem model.
29
+ *
30
+ * This method cann be called directly from the actions class.
31
+ *
32
+ * @param string $name The name of the root menu item to return
33
+ * @return ioMenuItem
34
+ */
35
+ public function getDoctrineMenu ($ name )
36
+ {
37
+ return $ this ->_pluginConfiguration ->getMenuManager ()
38
+ ->getMenu ($ name );
39
+ }
40
+
41
+ /**
42
+ * Listener method for method_not_found events
43
+ *
44
+ * This allows any public other methods in this class to be called as
45
+ * if they were in the actions class.
46
+ */
47
+ public function extend (sfEvent $ event )
48
+ {
49
+ $ this ->_subject = $ event ->getSubject ();
50
+ $ method = $ event ['method ' ];
51
+ $ arguments = $ event ['arguments ' ];
52
+
53
+ if (method_exists ($ this , $ method ))
54
+ {
55
+ $ result = call_user_func_array (array ($ this , $ method ), $ arguments );
56
+
57
+ $ event ->setReturnValue ($ result );
58
+
59
+ return true ;
60
+ }
61
+ else
62
+ {
63
+ return false ;
64
+ }
65
+ }
66
+ }
0 commit comments