message = $message; // Get the message queue if requested and available $app = JFactory::$application; if (!$ignoreMessages && !is_null($app) && is_callable(array($app, 'getMessageQueue'))) { $messages = $app->getMessageQueue(); // Build the sorted messages list if (is_array($messages) && count($messages)) { foreach ($messages as $message) { if (isset($message['type']) && isset($message['message'])) { $lists[$message['type']][] = $message['message']; } } } // If messages exist add them to the output if (isset($lists) && is_array($lists)) { $this->messages = $lists; } } // Check if we are dealing with an error if ($response instanceof Exception) { // Prepare the error response $this->success = false; $this->message = $response->getMessage(); } else { // Prepare the response data $this->success = !$error; $this->data = $response; } } /** * Magic toString method for sending the response in JSON format * * @return string The response in JSON format * * @since 3.1 */ public function __toString() { return json_encode($this); } }