This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Cmf \Bundle \MenuBundle ;
13
13
14
+ use Knp \Menu \Factory \ExtensionInterface ;
14
15
use Knp \Menu \FactoryInterface ;
16
+ use LogicException ;
15
17
use Psr \Log \LoggerInterface ;
16
18
use Symfony \Component \Routing \Exception \RouteNotFoundException ;
17
19
@@ -69,10 +71,28 @@ public function createItem($name, array $options = array())
69
71
}
70
72
71
73
// remove route and content options
72
- unset($ options ['route ' ]);
73
- unset($ options ['content ' ]);
74
+ unset($ options ['route ' ], $ options ['content ' ]);
74
75
75
76
return $ this ->innerFactory ->createItem ($ name , $ options );
76
77
}
77
78
}
79
+
80
+ /**
81
+ * Forward adding extensions to the wrapped factory.
82
+ *
83
+ * @param ExtensionInterface $extension
84
+ * @param int $priority
85
+ *
86
+ * @throws \Exception if the inner factory does not implement the addExtension method.
87
+ */
88
+ public function addExtension (ExtensionInterface $ extension , $ priority = 0 )
89
+ {
90
+ if (!method_exists ($ this ->innerFactory , 'addExtension ' )) {
91
+ throw new LogicException (sprintf (
92
+ 'Wrapped factory "%s" does not have the method "addExtension". ' ,
93
+ get_class ($ this ->innerFactory )
94
+ ));
95
+ }
96
+ $ this ->innerFactory ->addExtension ($ extension , $ priority );
97
+ }
78
98
}
You can’t perform that action at this time.
0 commit comments