Skip to content

Instantly share code, notes, and snippets.

@ChrisFrench
Created December 10, 2014 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisFrench/6ae7a595461d8b560c4e to your computer and use it in GitHub Desktop.
Save ChrisFrench/6ae7a595461d8b560c4e to your computer and use it in GitHub Desktop.
<?php
namespace Api\Site\Controllers;
class Base extends \Dsc\Controller {
public function getInputs() {
$array = (array) json_decode( file_get_contents('php://input') );
if(empty($array)) {
$array = $this->input->getArray();
}
return $array;
}
public function afterroute() {
echo $this->outputJson ( $this->getJsonResponse ( $this->app->get('results') ) );
}
public function apiError($message, $code = 400) {
echo $this->outputJson ( $this->getJsonResponse ( array (
'message' => $message,
'code' => $code
) ) );
die ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment