/** * Creates the controller and attaches observers to it * * @param Request $request * @param string $className */ protected function _createController(Request $request, $className) { $template = new \Text_Template(__DIR__ . DIRECTORY_SEPARATOR . 'Spy' . DIRECTORY_SEPARATOR . 'Controller.php.dist'); $spyControllerName = 'SpyController' . rand(0, time()); $template->setVar(array('spyController' => $spyControllerName, 'userController' => $className)); eval($template->render()); $this->_currentController = new $spyControllerName($request, $this->getResponse(), $this->getParams()); foreach ($this->_observers as $observer) { $this->_currentController->attach($observer); } if (!$this->_currentController instanceof ActionController) { require_once 'Zend/Controller/Dispatcher/Exception.php'; throw new DispatcherException('Controller "' . $className . '" is not an instance of Zend_Controller_Action_Interface'); } return $this->_currentController; }