ZF\Apigility\Admin\Controller\AuthorizationController::authorizationAction PHP Method

authorizationAction() public method

public authorizationAction ( )
    public function authorizationAction()
    {
        $request = $this->getRequest();
        $version = $request->getQuery('version', 1);
        $model = $this->getModel();
        switch ($request->getMethod()) {
            case $request::METHOD_GET:
                $entity = $model->fetch($version);
                break;
            case $request::METHOD_PUT:
                $this->getResponse()->getHeaders()->addHeaderLine('X-Deprecated', 'This service has deprecated the PUT method; please use PATCH');
                // intentionally fall through
            // intentionally fall through
            case $request::METHOD_PATCH:
                $entity = $model->update($this->bodyParams(), $version);
                break;
            default:
                return new ApiProblemResponse(new ApiProblem(405, 'Only the methods GET and PUT are allowed for this URI'));
        }
        $entity = new Entity($entity, null);
        $entity->getLinks()->add(Link::factory(['rel' => 'self', 'route' => ['name' => 'zf-apigility/api/module/authorization', 'params' => ['name' => $this->moduleName], 'options' => ['query' => ['version' => $version]]]]));
        return new ViewModel(['payload' => $entity]);
    }