protected function _actionRender(KControllerContextInterface $context) { $result = false; if($this->execute('browse', $context) !== false) { //Do not call parent. Parent will re-execute. $result = KControllerView::_actionRender($context); } return $result; }
/** * Get action * * This function translates a GET request into a read or browse action. If the view name is singular a read action * will be executed, if plural a browse action will be executed. * * @param KControllerContextInterface $context A command context object * @return string|bool The rendered output of the view or FALSE if something went wrong */ protected function _actionRender(KControllerContextInterface $context) { $result = false; //Check if we are reading or browsing $action = $this->getView()->isCollection() ? 'browse' : 'read'; //Execute the action if ($this->execute($action, $context) !== false) { $result = parent::_actionRender($context); } return $result; }
/** * Render an error * * @throws InvalidArgumentException If the action parameter is not an instance of KException * @param KControllerContextInterface $context A controller context object * @return string */ protected function _actionRender(KControllerContextInterface $context) { //Check an exception was passed if (!isset($context->param) && !$context->param instanceof KException) { throw new InvalidArgumentException("Action parameter 'exception' [KException] is required"); } //Set the exception data in the view $exception = $context->param; //If the error code does not correspond to a status message, use 500 $code = $exception->getCode(); if (!isset(KHttpResponse::$status_messages[$code])) { $code = '500'; } $message = KHttpResponse::$status_messages[$code]; //Get the exception back trace $traces = $this->getBackTrace($exception); //Traverse up the trace stack to find the actual function that was not found if (isset($traces[0]['function']) && $traces[0]['function'] == '__call') { foreach ($traces as $trace) { if ($trace['function'] != '__call') { $message = "Call to undefined method : " . $trace['class'] . $trace['type'] . $trace['function']; $file = isset($trace['file']) ? $trace['file'] : ''; $line = isset($trace['line']) ? $trace['line'] : ''; $function = $trace['function']; $class = $trace['class']; $args = isset($trace['args']) ? $trace['args'] : ''; $info = isset($trace['info']) ? $trace['info'] : ''; break; } } } else { $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); $function = isset($traces[0]['function']) ? $traces[0]['function'] : ''; $class = isset($traces[0]['class']) ? $traces[0]['class'] : ''; $args = isset($traces[0]['args']) ? $traces[0]['args'] : ''; $info = isset($traces[0]['info']) ? $traces[0]['info'] : ''; } //Create the exception message if (!ini_get('display_errors')) { $traces = array(); } $this->getView()->exception = get_class($exception); $this->getView()->code = $code; $this->getView()->message = $message; $this->getView()->file = $file; $this->getView()->line = $line; $this->getView()->function = $function; $this->getView()->class = $class; $this->getView()->args = $args; $this->getView()->info = $info; $this->getView()->trace = $traces; $this->getView()->level = $exception instanceof KExceptionError ? $exception->getSeverityMessage() : false; //Render the exception $result = parent::_actionRender($context); return $result; }