public function totals() { $result = null; $app = JFactory::getApplication(); try { self::validateRequest(); if ($app->input->getMethod() != 'GET') { throw new Exception('You cannot use other method than GET to fetch totals'); } //handle unexpected warnings from model set_error_handler(array($this, 'exception_error_handler')); $result = ImcFrontendHelper::getTotals(); restore_error_handler(); $app->enqueueMessage('size: ' . sizeof($result), 'info'); echo new JResponseJson($result, 'Totals fetched successfully'); } catch (Exception $e) { header("HTTP/1.0 202 Accepted"); echo new JResponseJson($e); } }