src/Graviton/SecurityBundle/Controller/WhoAmIController.php
public function whoAmIAction()
    {
        /** @var SecurityUser $securityUser */
        $securityUser = $this->getSecurityUser();

        /** @var Response $response */
        $response = $this->getResponse();
        $response->headers->set('Content-Type', 'application/json');

        if (!$securityUser) {
            $response->setContent(json_encode(['Security is not enabled']));
            $response->setStatusCode(Response::HTTP_METHOD_NOT_ALLOWED);
            return $response;
        }

        $response->setContent($this->restUtils->serialize($securityUser->getUser()));
        $response->setStatusCode(Response::HTTP_OK);

        return $response;
    }
public function whoAmIAction()
    {
        /** @var SecurityUser $securityUser */
        $securityUser = $this->getSecurityUser();

        /** @var Response $response */
        $response = $this->getResponse();
        $response->headers->set('Content-Type', 'application/json');

        if (!$securityUser) {
            $response->setContent(json_encode(['Security is not enabled']));
            $response->setStatusCode(Response::HTTP_METHOD_NOT_ALLOWED);
            return $response;
        }

        $response->setContent($this->restUtils->serialize($securityUser->getUser()));
        $response->setStatusCode(Response::HTTP_OK);

        return $response;
    }
public function whoAmIAction ( ) { /** @var SecurityUser $securityUser */ $ securityUser = $ this -> getSecurityUser ( ) ; /** @var Response $response */ $ response = $ this -> getResponse ( ) ; $ response -> headers -> set ( 'Content-Type' , 'application/json' ) ; if ( ! $ securityUser ) { $ response -> setContent ( json_encode ( [ 'Security is not enabled' ] ) ) ; $ response -> setStatusCode ( Response :: HTTP_METHOD_NOT_ALLOWED ) ; return $ response ; } $ response -> setContent ( $ this -> restUtils -> serialize ( $ securityUser -> getUser ( ) ) ) ; $ response -> setStatusCode ( Response :: HTTP_OK ) ; return $ response ; }
Currently authenticated user information.
If security is not enabled then header will be Not Allowed.
If User not found using correct header Anonymous user
Serialised Object transformer

@return Response $response Response with result or error
Currently authenticated user information . If security is not enabled then header will be Not Allowed . If User not found using correct header Anonymous user Serialised Object transformer