Neos\Flow\Security\Context::clearContext PHP Method

clearContext() public method

Clears the security context.
public clearContext ( ) : void
return void
    public function clearContext()
    {
        $this->roles = null;
        $this->contextHash = null;
        $this->tokens = [];
        $this->activeTokens = [];
        $this->inactiveTokens = [];
        $this->request = null;
        $this->csrfProtectionTokens = [];
        $this->interceptedRequest = null;
        $this->authorizationChecksDisabled = false;
        $this->initialized = false;
    }

Usage Example

 /**
  * Sends the given HTTP request
  *
  * @param Http\Request $httpRequest
  * @return Http\Response
  * @throws Http\Exception
  * @api
  */
 public function sendRequest(Http\Request $httpRequest)
 {
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if (!$requestHandler instanceof FunctionalTestRequestHandler) {
         throw new Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749);
     }
     $this->securityContext->clearContext();
     $this->validatorResolver->reset();
     $response = new Http\Response();
     $componentContext = new ComponentContext($httpRequest, $response);
     $requestHandler->setComponentContext($componentContext);
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get(\Neos\Flow\Http\Component\ComponentChain::class);
     $componentContext = new ComponentContext($httpRequest, $response);
     try {
         $baseComponentChain->handle($componentContext);
     } catch (\Throwable $throwable) {
         $this->prepareErrorResponse($throwable, $componentContext->getHttpResponse());
     } catch (\Exception $exception) {
         $this->prepareErrorResponse($exception, $componentContext->getHttpResponse());
     }
     $session = $this->bootstrap->getObjectManager()->get(SessionInterface::class);
     if ($session->isStarted()) {
         $session->close();
     }
     $this->persistenceManager->clearState();
     return $componentContext->getHttpResponse();
 }
All Usage Examples Of Neos\Flow\Security\Context::clearContext