Skip to content

Commit

Permalink
PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbung authored Aug 11, 2017
1 parent 2cf5557 commit 58d3266
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions code/site/controllers/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class ApiControllerHttp extends ApiController
{

public $callbackname = 'callback';

/**
Expand Down Expand Up @@ -62,26 +61,28 @@ public function display($cachable = false, $urlparams = array())
}

/**
* Method description
* Send the response in the correct format
*
* @param OBJECT $exception exception
* @param OBJECT $response exception
*
* @return json
*
* @since 1.0
* @since 2.0
*/
private function respond($response)
{
$app = JFactory::getApplication();
$accept = $app->input->server->get('HTTP_ACCEPT', 'application/json', 'STRING');
$compatibility = $app->input->server->get('HTTP_X_COMPATIBILITY_MODE', 0, 'INT');

// Enforce JSON in compatibility mode
if ($compatibility)
{
$output = new \stdClass;
header("Content-type: application/json");
if ($response instanceof Exception) {

if ($response instanceof Exception)
{
$output->message = $response->getMessage();
$output->code = $response->getCode();
}
Expand All @@ -95,7 +96,8 @@ private function respond($response)
die();
}

switch($accept) {
switch ($accept)
{
case 'application/json':
default:
header("Content-type: application/json");
Expand All @@ -108,16 +110,18 @@ private function respond($response)
break;
}

$output_overrride = JPATH_ROOT . '/templates/' . $app->getTemplate() . '/'.$format.'/api.php';
if (file_exists($output_overrride)) {
$output_overrride = JPATH_ROOT . '/templates/' . $app->getTemplate() . '/' . $format . '/api.php';

if (file_exists($output_overrride))
{
require_once $output_overrride;
}
else
{
require_once JPATH_COMPONENT . '/libraries/response/'.$format.'response.php';
require_once JPATH_COMPONENT . '/libraries/response/' . $format . 'response.php';
}

$classname = 'API'.ucfirst($format).'Response';
$classname = 'API' . ucfirst($format) . 'Response';
$output = new $classname($response);

echo $output->__toString();
Expand Down

0 comments on commit 58d3266

Please sign in to comment.