/** * Runs the widget subclass and renders the view's content * @final * @return string */ public final function render() { $this->run(); $this->_view->setVariables(get_object_vars($this)); $this->_view->render(); return $this->_view->content(); }
/** * Runs this controller action, printing its view * @final * @return void */ public final function run() { $action = $this->_response->action() . 'Action'; $params = $this->_response->params(); // get variables of the abstract controller $vars = get_object_vars($this); if (is_callable(array($this, $action))) { //TODO: put these assertions in a private method $refl = new ReflectionAnnotatedMethod($this, $action); if (!$this->_authorize($refl->getAllAnnotations())) { throw new UserError('You do not have permission to access this action'); } if (count($params) < $refl->getNumberOfRequiredParameters()) { throw new UserError('The URL misses some parameters'); } call_user_func_array(array($this, $action), $params); $this->flush(); // closes the database connection because only a controller can access it $this->close(); } // get only variables set in the controller instance $vars = array_diff_key(get_object_vars($this), $vars); $this->_view->setVariables($vars); if ($this->_request->json() || $this->_request->ajax()) { $this->disableDecorator(); } if (!is_null($this->_decorator)) { $this->_view->setDecorator($this->_decorator); } $this->_view->render(); $this->_view->show(); //FIXME: in the view, we need to know which constraints are in use, in order to hide some information like links to add an item }