src/API.php
public function execute(RestRequestModel $apiRequest)
    {
        $result = new ApiResultModel();

        list($controller, $action, $args) = $this->resolveController($apiRequest->getRoute(), $apiRequest->getPath());

        $actionReader = new ActionReader($controller);

        if ($apiRequest->getMethod() == 'OPTIONS') {
            $ack = $this->optionsAck($actionReader, $action);

            return $result
                ->setContent($this->serialize($ack))
                ->setJson(true)
                ->setHeaders(['Allow' => 'OPTIONS, GET, POST'])
                ->setStatusCode(200);
        }

        $ack = $this->callAction($actionReader, $apiRequest, $action, $args);

        return $result
            ->setContent($this->serialize($ack))
            ->setJson(true) // serialized ^
            ->setStatusCode($ack->getServerCode());
    }
public function execute(RestRequestModel $apiRequest)
    {
        $result = new ApiResultModel();

        list($controller, $action, $args) = $this->resolveController($apiRequest->getRoute(), $apiRequest->getPath());

        $actionReader = new ActionReader($controller);

        if ($apiRequest->getMethod() == 'OPTIONS') {
            $ack = $this->optionsAck($actionReader, $action);

            return $result
                ->setContent($this->serialize($ack))
                ->setJson(true)
                ->setHeaders(['Allow' => 'OPTIONS, GET, POST'])
                ->setStatusCode(200);
        }

        $ack = $this->callAction($actionReader, $apiRequest, $action, $args);

        return $result
            ->setContent($this->serialize($ack))
            ->setJson(true) // serialized ^
            ->setStatusCode($ack->getServerCode());
    }
public function execute ( RestRequestModel $ apiRequest ) { $ result = new ApiResultModel ( ) ; list ( $ controller , $ action , $ args ) = $ this -> resolveController ( $ apiRequest -> getRoute ( ) , $ apiRequest -> getPath ( ) ) ; $ actionReader = new ActionReader ( $ controller ) ; if ( $ apiRequest -> getMethod ( ) == 'OPTIONS' ) { $ ack = $ this -> optionsAck ( $ actionReader , $ action ) ; return $ result -> setContent ( $ this -> serialize ( $ ack ) ) -> setJson ( true ) -> setHeaders ( [ 'Allow' => 'OPTIONS, GET, POST' ] ) -> setStatusCode ( 200 ) ; } $ ack = $ this -> callAction ( $ actionReader , $ apiRequest , $ action , $ args ) ; return $ result -> setContent ( $ this -> serialize ( $ ack ) ) -> setJson ( true ) // serialized ^ -> setStatusCode ( $ ack -> getServerCode ( ) ) ; }
Execute API call.

@param RestRequestModel $apiRequest

@throws \Exception

@return mixed
Execute API call .