public function preDispatch() { $controller = $this->getActionController(); $controllerName = get_class($controller); if ($this->serviceManager->has($controllerName)) { $this->serviceManager->setService('controller', $controller); if (!$this->serviceManager->get($controllerName)) { throw new \Exception('Invalid Controller'); } } }