public function index()
 {
     // Prepare
     ApiRequestSerialiser::execute($this);
     ApiAuthenticator::execute($this);
     // Generate
     if ($this->status === 200) {
         $output = array();
         $implementerclass = $this->getImplementerClass();
         if (!is_null($implementerclass)) {
             $this->implementer = new $implementerclass();
             $method = $this->method;
             try {
                 $this->implementer->{$method}($this);
             } catch (Exception $except) {
                 if ($this->status === 200) {
                     $this->setError(array("status" => 500, "dev" => "Error processing request: please check your syntax against the request definition", "user" => "This request could not be processed"));
                 }
             }
         } else {
             if (Director::isDev()) {
                 $this->testOutput();
             }
         }
     } else {
         $this->populateErrorResponse();
     }
     // Deliver
     $this->setStandardHeaders();
     $ApiResponse = $this->getResponseSerialiser();
     // Hook to allow analytics tracking, external logging, etc
     $this->extend('updateController', $this);
     return $ApiResponse->execute($this);
 }
 /**
  * Entry function.
  * @param $controller
  */
 public static function execute($controller)
 {
     $serialiser = new ApiRequestSerialiser();
     $serialiser->parseRequestCase($controller);
     if (!$serialiser->parseRequestParams($controller)) {
         return;
     }
     if (!$serialiser->parseRequestVars($controller)) {
         return;
     }
     $serialiser->parseRequestFields($controller);
     $serialiser->parseRequestFormat($controller);
     $serialiser->parseRequestTest($controller);
     // Filters, sorting and pagination only apply if we're returning more than one record
     if (isset($serialiser->responses->{"200"}->schema->type) && $serialiser->responses->{"200"}->schema->type === 'array') {
         $serialiser->parseRequestSort($controller);
         $serialiser->parseRequestLimit($controller);
     }
 }