1212use Interop \Container \ContainerInterface ;
1313use Zend \EventManager \EventManagerAwareInterface ;
1414use Zend \EventManager \SharedEventManagerInterface ;
15- use Zend \Mvc \Exception ;
1615use Zend \ServiceManager \AbstractPluginManager ;
1716use Zend \ServiceManager \ConfigInterface ;
1817use Zend \ServiceManager \Exception \InvalidServiceException ;
@@ -46,17 +45,17 @@ class ControllerManager extends AbstractPluginManager
4645 * event manager and plugin manager.
4746 *
4847 * @param ConfigInterface|ContainerInterface $container
49- * @param array $v3config
48+ * @param array $config
5049 */
51- public function __construct ($ configOrContainerInstance , array $ v3config = [])
50+ public function __construct ($ configOrContainerInstance , array $ config = [])
5251 {
5352 $ this ->addInitializer ([$ this , 'injectEventManager ' ]);
5453 $ this ->addInitializer ([$ this , 'injectPluginManager ' ]);
55- parent ::__construct ($ configOrContainerInstance , $ v3config );
54+ parent ::__construct ($ configOrContainerInstance , $ config );
5655 }
5756
5857 /**
59- * Validate a plugin (v3)
58+ * Validate a plugin
6059 *
6160 * {@inheritDoc}
6261 */
@@ -71,26 +70,6 @@ public function validate($plugin)
7170 }
7271 }
7372
74- /**
75- * Validate a plugin (v2)
76- *
77- * {@inheritDoc}
78- *
79- * @throws Exception\InvalidControllerException
80- */
81- public function validatePlugin ($ plugin )
82- {
83- try {
84- $ this ->validate ($ plugin );
85- } catch (InvalidServiceException $ e ) {
86- throw new Exception \InvalidControllerException (
87- $ e ->getMessage (),
88- $ e ->getCode (),
89- $ e
90- );
91- }
92- }
93-
9473 /**
9574 * Initializer: inject EventManager instance
9675 *
@@ -101,63 +80,33 @@ public function validatePlugin($plugin)
10180 * the shared EM injection needs to happen; the conditional will always
10281 * pass.
10382 *
104- * @param ContainerInterface|DispatchableInterface $first Container when
105- * using zend-servicemanager v3; controller under v2.
106- * @param DispatchableInterface|ContainerInterface $second Controller when
107- * using zend-servicemanager v3; container under v2.
83+ * @param ContainerInterface $container
84+ * @param DispatchableInterface $controller
10885 */
109- public function injectEventManager ($ first , $ second )
86+ public function injectEventManager (ContainerInterface $ container , $ controller )
11087 {
111- if ($ first instanceof ContainerInterface) {
112- $ container = $ first ;
113- $ controller = $ second ;
114- } else {
115- $ container = $ second ;
116- $ controller = $ first ;
117- }
118-
11988 if (! $ controller instanceof EventManagerAwareInterface) {
12089 return ;
12190 }
12291
12392 $ events = $ controller ->getEventManager ();
12493 if (! $ events || ! $ events ->getSharedManager () instanceof SharedEventManagerInterface) {
125- // For v2, we need to pull the parent service locator
126- if (! method_exists ($ container , 'configure ' )) {
127- $ container = $ container ->getServiceLocator () ?: $ container ;
128- }
129-
13094 $ controller ->setEventManager ($ container ->get ('EventManager ' ));
13195 }
13296 }
13397
13498 /**
13599 * Initializer: inject plugin manager
136100 *
137- * @param ContainerInterface|DispatchableInterface $first Container when
138- * using zend-servicemanager v3; controller under v2.
139- * @param DispatchableInterface|ContainerInterface $second Controller when
140- * using zend-servicemanager v3; container under v2.
101+ * @param ContainerInterface $container
102+ * @param DispatchableInterface $controller
141103 */
142- public function injectPluginManager ($ first , $ second )
104+ public function injectPluginManager (ContainerInterface $ container , $ controller )
143105 {
144- if ($ first instanceof ContainerInterface) {
145- $ container = $ first ;
146- $ controller = $ second ;
147- } else {
148- $ container = $ second ;
149- $ controller = $ first ;
150- }
151-
152106 if (! method_exists ($ controller , 'setPluginManager ' )) {
153107 return ;
154108 }
155109
156- // For v2, we need to pull the parent service locator
157- if (! method_exists ($ container , 'configure ' )) {
158- $ container = $ container ->getServiceLocator () ?: $ container ;
159- }
160-
161110 $ controller ->setPluginManager ($ container ->get ('ControllerPluginManager ' ));
162111 }
163112}
0 commit comments