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


PHP TemplateResponse::setStatus方法代码示例

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


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

示例1: index

 /**
  * CAUTION: the @Stuff turns off security checks; for this page no admin is
  *          required and no CSRF check. If you don't know what CSRF is, read
  *          it up in the docs or you might create a security hole. This is
  *          basically the only required method to add this exemption, don't
  *          add it to any other method if you don't exactly know what it does
  *
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $params = ['user' => $this->userId];
     $response = new TemplateResponse('user_permission', 'main', $params);
     // templates/main.php
     $response->setStatus(Http::STATUS_UNAUTHORIZED);
     return $response;
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:18,代码来源:pagecontroller.php

示例2: afterException

 /**
  * Return 403 page in case of an exception
  * @param \OCP\AppFramework\Controller $controller
  * @param string $methodName
  * @param \Exception $exception
  * @return TemplateResponse
  * @throws \Exception
  */
 public function afterException($controller, $methodName, \Exception $exception)
 {
     if ($exception instanceof NotAdminException) {
         $response = new TemplateResponse('core', '403', array(), 'guest');
         $response->setStatus(Http::STATUS_FORBIDDEN);
         return $response;
     }
     throw $exception;
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:17,代码来源:SubadminMiddleware.php

示例3: testAfterExceptionReturnsTemplateResponse

 /**
  * @dataProvider exceptionProvider
  * @param SecurityException $exception
  */
 public function testAfterExceptionReturnsTemplateResponse(SecurityException $exception)
 {
     $this->request = new Request(['server' => ['HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'REQUEST_URI' => 'owncloud/index.php/apps/specialapp']], $this->getMock('\\OCP\\Security\\ISecureRandom'), $this->getMock('\\OCP\\IConfig'));
     $this->middleware = $this->getMiddleware(false, false);
     $this->logger->expects($this->once())->method('debug')->with($exception->getMessage());
     $response = $this->middleware->afterException($this->controller, 'test', $exception);
     $expected = new TemplateResponse('core', '403', ['file' => $exception->getMessage()], 'guest');
     $expected->setStatus($exception->getCode());
     $this->assertEquals($expected, $response);
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:14,代码来源:SecurityMiddlewareTest.php

示例4: errorPage

 /**
  * @PublicPage
  * @NoCSRFRequired
  * @Guest
  *
  * Generates an error page based on the error code
  *
  * @param int $code
  *
  * @return TemplateResponse
  */
 public function errorPage($code)
 {
     $appName = $this->appName;
     $message = $this->request->getCookie('galleryErrorMessage');
     $params = ['appName' => $appName, 'message' => $message, 'code' => $code];
     $errorTemplate = new TemplateResponse($appName, 'index', $params, 'guest');
     $errorTemplate->setStatus($code);
     $errorTemplate->invalidateCookie('galleryErrorMessage');
     return $errorTemplate;
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:21,代码来源:pagecontroller.php

示例5: errorPage

 /**
  * @PublicPage
  * @NoCSRFRequired
  * @Guest
  *
  * Generates an error page based on the error code
  *
  * @param string $message
  * @param int $code
  *
  * @return TemplateResponse
  */
 public function errorPage($message, $code)
 {
     $appName = $this->appName;
     $params = ['appName' => $appName, 'message' => $message, 'code' => $code];
     $errorTemplate = new TemplateResponse($appName, 'index', $params, 'guest');
     $errorTemplate->setStatus($code);
     return $errorTemplate;
 }
开发者ID:AARNet,项目名称:galleryplus,代码行数:20,代码来源:pagecontroller.php

示例6: afterException

 /**
  * If an SecurityException is being caught, ajax requests return a JSON error
  * response and non ajax requests redirect to the index
  * @param Controller $controller the controller that is being called
  * @param string $methodName the name of the method that will be called on
  *                           the controller
  * @param \Exception $exception the thrown exception
  * @throws \Exception the passed in exception if it cant handle it
  * @return Response a Response object or null in case that the exception could not be handled
  */
 public function afterException($controller, $methodName, \Exception $exception)
 {
     if ($exception instanceof SecurityException) {
         if (stripos($this->request->getHeader('Accept'), 'html') === false) {
             $response = new JSONResponse(array('message' => $exception->getMessage()), $exception->getCode());
         } else {
             if ($exception instanceof NotLoggedInException) {
                 // TODO: replace with link to route
                 $url = $this->urlGenerator->getAbsoluteURL('index.php');
                 $url .= '?redirect_url=' . urlencode($this->request->server['REQUEST_URI']);
                 $response = new RedirectResponse($url);
             } else {
                 $response = new TemplateResponse('core', '403', ['file' => $exception->getMessage()], 'guest');
                 $response->setStatus($exception->getCode());
             }
         }
         $this->logger->debug($exception->getMessage());
         return $response;
     }
     throw $exception;
 }
开发者ID:gmurayama,项目名称:core,代码行数:31,代码来源:securitymiddleware.php

示例7: testAfterRegularException

 /**
  * @expectedException \Exception
  */
 public function testAfterRegularException()
 {
     $expectedResponse = new TemplateResponse('core', '403', array(), 'guest');
     $expectedResponse->setStatus(403);
     $this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception());
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:9,代码来源:SubadminMiddlewareTest.php


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