/** * Performs the action * * @param string, action_name, the action to perform * @todo still to refactor. * @todo do not try to create the ``index" method, just throw an error. * @throws RoutingException if the action cannot be invoked and the index method is not defined */ private function perform_action($action_name) { $forbidden_actions = array('process', '__construct', '__destruct', '__common'); $action = $this->createMethod($action_name); if (is_null($action_name) || in_array($action_name, $forbidden_actions) || !$action || $action->isStatic()) { $action_name = 'index'; $action = $this->createMethod($action_name); if (!$action || $action->isStatic()) { throw new RoutingException('Cannot invoke default action, `index` for this Route!', 'Method named `index` is not defined in class: `' . $this->getClassName() . '`'); } } $this->params['action'] = strtolower($action_name); $this->template->assign('__action', $this->params['action']); // invoke the action. $action->invoke($this); if ($this->action_performed) { return; } $this->render(); }
/** * Performs the action * * The magic __common method is also invoked just before the action to perform * * @param string, action_name, the action to perform * @todo still to refactor. * @todo do not try to create the ``index" method, just throw an error. * @throws RoutingException if the action cannot be invoked and the index method is not defined */ private function perform_action($action_name) { $forbidden_actions = array('process', '__construct', '__destruct', '__common'); $action = $this->createMethod($action_name); if (is_null($action_name) || in_array($action_name, $forbidden_actions) || !$action || $action->isStatic()) { $action_name = 'index'; $action = $this->createMethod($action_name); if (!$action || $action->isStatic()) { throw new RoutingException('Cannot invoke default action, ``index" for this Route!', 'Method named ``index" is not defined in class: ' . $this->getClassName()); } } $this->params['action'] = strtolower($action_name); $this->template->assign('__action', $this->params['action']); // $this->logger->debug('Action:: ' . strtolower($action_name)); // quickly load the common magick method. // if ($_common= $this->createMethod('__common')) { // $_common->invoke($this); // } // invoke the action. $action->invoke($this); if ($this->action_performed) { return; } $this->render(); }