当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::clearContext方法代码示例

本文整理汇总了PHP中TYPO3\Flow\Security\Context::clearContext方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::clearContext方法的具体用法?PHP Context::clearContext怎么用?PHP Context::clearContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\Flow\Security\Context的用法示例。


在下文中一共展示了Context::clearContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendRequest

 /**
  * 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();
     $requestHandler->setHttpRequest($httpRequest);
     $requestHandler->setHttpResponse($response);
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get(\TYPO3\Flow\Http\Component\ComponentChain::class);
     $componentContext = new ComponentContext($httpRequest, $response);
     if (version_compare(PHP_VERSION, '6.0.0') >= 0) {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Throwable $throwable) {
             $this->prepareErrorResponse($throwable, $response);
         }
     } else {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Exception $exception) {
             $this->prepareErrorResponse($exception, $response);
         }
     }
     $session = $this->bootstrap->getObjectManager()->get(\TYPO3\Flow\Session\SessionInterface::class);
     if ($session->isStarted()) {
         $session->close();
     }
     $this->persistenceManager->clearState();
     return $response;
 }
开发者ID:vjanoch,项目名称:flow-development-collection,代码行数:42,代码来源:InternalRequestEngine.php

示例2: authenticateAccount

 /**
  * Prepares the environment for and conducts an account authentication
  *
  * @param Account $account
  * @return void
  */
 protected function authenticateAccount(Account $account)
 {
     $this->testingProvider->setAuthenticationStatus(TokenInterface::AUTHENTICATION_SUCCESSFUL);
     $this->testingProvider->setAccount($account);
     $this->securityContext->clearContext();
     /** @var RequestHandler $requestHandler */
     $this->securityContext->setRequest($this->mockActionRequest);
     $this->authenticationManager->authenticate();
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:15,代码来源:BehatHelperCommandController.php

示例3: authenticateAccount

 /**
  * Prepares the environment for and conducts an account authentication
  *
  * @param \TYPO3\Flow\Security\Account $account
  * @return void
  * @api
  */
 protected function authenticateAccount(\TYPO3\Flow\Security\Account $account)
 {
     $this->testingProvider->setAuthenticationStatus(\TYPO3\Flow\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL);
     $this->testingProvider->setAccount($account);
     $this->securityContext->clearContext();
     $requestHandler = self::$bootstrap->getActiveRequestHandler();
     $actionRequest = $this->route($requestHandler->getHttpRequest());
     $this->securityContext->setRequest($actionRequest);
     $this->authenticationManager->authenticate();
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:17,代码来源:FunctionalTestCase.php

示例4: sendRequest

 /**
  * Sends the given HTTP request
  *
  * @param \TYPO3\Flow\Http\Request $request
  * @return \TYPO3\Flow\Http\Response
  * @throws \TYPO3\Flow\Http\Exception
  * @api
  */
 public function sendRequest(Request $request)
 {
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if (!$requestHandler instanceof \TYPO3\Flow\Tests\FunctionalTestRequestHandler) {
         throw new \TYPO3\Flow\Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749);
     }
     $response = new Response();
     $requestHandler->setHttpRequest($request);
     $requestHandler->setHttpResponse($response);
     try {
         $actionRequest = $this->router->route($request);
         $this->securityContext->clearContext();
         $this->securityContext->setRequest($actionRequest);
         $this->validatorResolver->reset();
         $this->dispatcher->dispatch($actionRequest, $response);
         $session = $this->bootstrap->getObjectManager()->get('TYPO3\\Flow\\Session\\SessionInterface');
         if ($session->isStarted()) {
             $session->close();
         }
     } catch (\Exception $exception) {
         $pathPosition = strpos($exception->getFile(), 'Packages/');
         $filePathAndName = $pathPosition !== FALSE ? substr($exception->getFile(), $pathPosition) : $exception->getFile();
         $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
         $content = PHP_EOL . 'Uncaught Exception in Flow ' . $exceptionCodeNumber . $exception->getMessage() . PHP_EOL;
         $content .= 'thrown in file ' . $filePathAndName . PHP_EOL;
         $content .= 'in line ' . $exception->getLine() . PHP_EOL . PHP_EOL;
         $content .= \TYPO3\Flow\Error\Debugger::getBacktraceCode($exception->getTrace(), FALSE, TRUE) . PHP_EOL;
         if ($exception instanceof \TYPO3\Flow\Exception) {
             $statusCode = $exception->getStatusCode();
         } else {
             $statusCode = 500;
         }
         $response->setStatus($statusCode);
         $response->setContent($content);
         $response->setHeader('X-Flow-ExceptionCode', $exception->getCode());
         $response->setHeader('X-Flow-ExceptionMessage', $exception->getMessage());
     }
     return $response;
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:47,代码来源:InternalRequestEngine.php

示例5: sendRequest

 /**
  * 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();
     $requestHandler->setHttpRequest($httpRequest);
     $requestHandler->setHttpResponse($response);
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get(\TYPO3\Flow\Http\Component\ComponentChain::class);
     $componentContext = new ComponentContext($httpRequest, $response);
     try {
         $baseComponentChain->handle($componentContext);
     } catch (\Exception $exception) {
         $pathPosition = strpos($exception->getFile(), 'Packages/');
         $filePathAndName = $pathPosition !== false ? substr($exception->getFile(), $pathPosition) : $exception->getFile();
         $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
         $content = PHP_EOL . 'Uncaught Exception in Flow ' . $exceptionCodeNumber . $exception->getMessage() . PHP_EOL;
         $content .= 'thrown in file ' . $filePathAndName . PHP_EOL;
         $content .= 'in line ' . $exception->getLine() . PHP_EOL . PHP_EOL;
         $content .= Debugger::getBacktraceCode($exception->getTrace(), false, true) . PHP_EOL;
         if ($exception instanceof Exception) {
             $statusCode = $exception->getStatusCode();
         } else {
             $statusCode = 500;
         }
         $response->setStatus($statusCode);
         $response->setContent($content);
         $response->setHeader('X-Flow-ExceptionCode', $exception->getCode());
         $response->setHeader('X-Flow-ExceptionMessage', $exception->getMessage());
     }
     $session = $this->bootstrap->getObjectManager()->get(\TYPO3\Flow\Session\SessionInterface::class);
     if ($session->isStarted()) {
         $session->close();
     }
     return $response;
 }
开发者ID:patrickreck,项目名称:flow-development-collection,代码行数:48,代码来源:InternalRequestEngine.php


注:本文中的TYPO3\Flow\Security\Context::clearContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。