ZF\Apigility\Admin\Controller\AuthenticationController::authVersion2 PHP Метод

authVersion2() защищенный Метод

Manage the authentication API version 2
protected authVersion2 ( Zend\Http\Request $request ) : ZF\ContentNegotiation\ViewModel | ZF\ApiProblem\ApiProblemResponse | Zend\Http\Response
$request Zend\Http\Request
Результат ZF\ContentNegotiation\ViewModel | ZF\ApiProblem\ApiProblemResponse | Zend\Http\Response
    protected function authVersion2(Request $request)
    {
        $adapter = $this->params('authentication_adapter', false);
        if ($adapter) {
            $adapter = strtolower($adapter);
        }
        switch ($request->getMethod()) {
            case $request::METHOD_GET:
                if (!$adapter) {
                    return $this->fetchAuthenticationCollection();
                }
                return $this->fetchAuthenticationEntity($adapter);
            case $request::METHOD_POST:
                if ($adapter) {
                    $response = new ApiProblemResponse(new ApiProblem(405, 'Only the methods GET, PUT, and DELETE are allowed for this URI'));
                    $response->getHeaders()->addHeaderLine('Allow', 'GET, PUT, DELETE');
                    return $response;
                }
                return $this->createAuthenticationAdapter($this->bodyParams());
            case $request::METHOD_PUT:
                return $this->updateAuthenticationAdapter($adapter, $this->bodyParams());
            case $request::METHOD_DELETE:
                return $this->removeAuthenticationAdapter($adapter);
            default:
                return new ApiProblemResponse(new ApiProblem(405, 'Only the methods GET, POST, PUT, and DELETE are allowed for this URI'));
        }
    }