original_string: public function index(HTTPRequest $request)
      {
          //check authentication if enabled
          if ($this->authenticator) {
              $policy = $this->config()->authentication_policy;
              $authALL = $policy === true;
              $authMethod = is_array($policy) && in_array($request->httpMethod(), $policy);
  
              if ($authALL || $authMethod) {
                  $authResult = $this->authenticator->authenticate($request);
  
                  if ($authResult instanceof RESTfulAPIError) {
                      //Authentication failed return error to client
                      return $this->error($authResult);
                  }
              }
          }
  
          //pass control to query handler
          $data = $this->queryHandler->handleQuery($request);
          //catch + return errors
          if ($data instanceof RESTfulAPIError) {
              return $this->error($data);
          }
  
          //serialize response
          $json = $this->serializer->serialize($data);
          //catch + return errors
          if ($json instanceof RESTfulAPIError) {
              return $this->error($json);
          }
  
          //all is good reply normally
          return $this->answer($json);
      }
code: public function index(HTTPRequest $request)
      {
          //check authentication if enabled
          if ($this->authenticator) {
              $policy = $this->config()->authentication_policy;
              $authALL = $policy === true;
              $authMethod = is_array($policy) && in_array($request->httpMethod(), $policy);
  
              if ($authALL || $authMethod) {
                  $authResult = $this->authenticator->authenticate($request);
  
                  if ($authResult instanceof RESTfulAPIError) {
                      //Authentication failed return error to client
                      return $this->error($authResult);
                  }
              }
          }
  
          //pass control to query handler
          $data = $this->queryHandler->handleQuery($request);
          //catch + return errors
          if ($data instanceof RESTfulAPIError) {
              return $this->error($data);
          }
  
          //serialize response
          $json = $this->serializer->serialize($data);
          //catch + return errors
          if ($json instanceof RESTfulAPIError) {
              return $this->error($json);
          }
  
          //all is good reply normally
          return $this->answer($json);
      }
code_tokens: public function index ( HTTPRequest $ request ) { //check authentication if enabled if ( $ this -> authenticator ) { $ policy = $ this -> config ( ) -> authentication_policy ; $ authALL = $ policy === true ; $ authMethod = is_array ( $ policy ) && in_array ( $ request -> httpMethod ( ) , $ policy ) ; if ( $ authALL || $ authMethod ) { $ authResult = $ this -> authenticator -> authenticate ( $ request ) ; if ( $ authResult instanceof RESTfulAPIError ) { //Authentication failed return error to client return $ this -> error ( $ authResult ) ; } } } //pass control to query handler $ data = $ this -> queryHandler -> handleQuery ( $ request ) ; //catch + return errors if ( $ data instanceof RESTfulAPIError ) { return $ this -> error ( $ data ) ; } //serialize response $ json = $ this -> serializer -> serialize ( $ data ) ; //catch + return errors if ( $ json instanceof RESTfulAPIError ) { return $ this -> error ( $ json ) ; } //all is good reply normally return $ this -> answer ( $ json ) ; }
docstring: Main API hub switch
  All requests pass through here and are redirected depending on HTTP verb and params
  
  @todo move authentication check to another methode
  
  @param  HTTPRequest      $request    HTTP request
  @return string                       json object of the models found
docstring_tokens: Main API hub switch All requests pass through here and are redirected depending on HTTP verb and params