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


PHP IResponse::isSent方法代码示例

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


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

示例1: resolve

 /**
  * @param Translator $translator
  * @return string|NULL
  */
 public function resolve(Translator $translator)
 {
     if (!$this->session->isStarted() && $this->httpResponse->isSent()) {
         trigger_error("The advice of session locale resolver is required but the session has not been started and headers had been already sent. " . "Either start your sessions earlier or disabled the SessionResolver.", E_USER_WARNING);
         return NULL;
     }
     if (empty($this->localeSession->locale)) {
         return NULL;
     }
     $short = array_map(function ($locale) {
         return substr($locale, 0, 2);
     }, $translator->getAvailableLocales());
     if (!in_array(substr($this->localeSession->locale, 0, 2), $short, TRUE)) {
         return NULL;
     }
     return $this->localeSession->locale;
 }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:21,代码来源:SessionResolver.php

示例2: destroy

 /**
  * Destroys all data registered to a session.
  * @return void
  */
 public function destroy()
 {
     if (!self::$started) {
         throw new Nette\InvalidStateException('Session is not started.');
     }
     session_destroy();
     $_SESSION = NULL;
     self::$started = FALSE;
     if (!$this->response->isSent()) {
         $params = session_get_cookie_params();
         $this->response->deleteCookie(session_name(), $params['path'], $params['domain'], $params['secure']);
     }
 }
开发者ID:genextwebs,项目名称:dropbox-sample,代码行数:17,代码来源:Session.php

示例3: doProcessException

 public function doProcessException($e)
 {
     if (!$e instanceof BadRequestException && $this->httpResponse instanceof Response) {
         $this->httpResponse->warnOnBuffer = false;
     }
     if (!$this->httpResponse->isSent()) {
         $this->httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() ?: 404 : 500);
     }
     $requests = $this->getRequests();
     $request = end($requests) ?: $this->initialRequest;
     $args = ['exception' => $e, 'request' => $request];
     $errorPresenter = $request ? $this->findErrorPresenter($request->getPresenterName()) : $this->errorPresenter;
     if ($this->getPresenter() instanceof Presenter) {
         try {
             $this->getPresenter()->forward(":{$errorPresenter}:", $args);
         } catch (AbortException $_) {
             $this->processRequest($this->getPresenter()->getLastCreatedRequest());
         }
     } else {
         $this->processRequest(new Request($errorPresenter, Request::FORWARD, $args));
     }
 }
开发者ID:enumag,项目名称:application,代码行数:22,代码来源:AbstractApplication.php

示例4: processException

 /**
  * @return void
  */
 public function processException(\Exception $e)
 {
     if (!$this->httpResponse->isSent()) {
         $this->httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() ?: 404 : 500);
     }
     $args = array('exception' => $e, 'request' => end($this->requests) ?: NULL);
     if ($this->presenter instanceof UI\Presenter) {
         try {
             $this->presenter->forward(":{$this->errorPresenter}:", $args);
         } catch (AbortException $foo) {
             $this->processRequest($this->presenter->getLastCreatedRequest());
         }
     } else {
         $this->processRequest(new Request($this->errorPresenter, Request::FORWARD, $args));
     }
 }
开发者ID:rostenkowski,项目名称:nette,代码行数:19,代码来源:Application.php

示例5: run

 /**
  * @return Nette\Application\IResponse
  */
 public function run(Application\Request $request)
 {
     try {
         // STARTUP
         $this->request = $request;
         $this->payload = new \stdClass();
         $this->setParent($this->getParent(), $request->getPresenterName());
         if (!$this->httpResponse->isSent()) {
             $this->httpResponse->addHeader('Vary', 'X-Requested-With');
         }
         $this->initGlobalParameters();
         $this->checkRequirements($this->getReflection());
         $this->startup();
         if (!$this->startupCheck) {
             $class = $this->getReflection()->getMethod('startup')->getDeclaringClass()->getName();
             throw new Nette\InvalidStateException("Method {$class}::startup() or its descendant doesn't call parent::startup().");
         }
         // calls $this->action<Action>()
         $this->tryCall($this->formatActionMethod($this->action), $this->params);
         // autoload components
         foreach ($this->globalParams as $id => $foo) {
             $this->getComponent($id, FALSE);
         }
         if ($this->autoCanonicalize) {
             $this->canonicalize();
         }
         if ($this->httpRequest->isMethod('head')) {
             $this->terminate();
         }
         // SIGNAL HANDLING
         // calls $this->handle<Signal>()
         $this->processSignal();
         // RENDERING VIEW
         $this->beforeRender();
         // calls $this->render<View>()
         $this->tryCall($this->formatRenderMethod($this->view), $this->params);
         $this->afterRender();
         // save component tree persistent state
         $this->saveGlobalState();
         if ($this->isAjax()) {
             $this->payload->state = $this->getGlobalState();
         }
         // finish template rendering
         $this->sendTemplate();
     } catch (Application\AbortException $e) {
         // continue with shutting down
         if ($this->isAjax()) {
             try {
                 $hasPayload = (array) $this->payload;
                 unset($hasPayload['state']);
                 if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) {
                     $this->snippetMode = TRUE;
                     $this->response->send($this->httpRequest, $this->httpResponse);
                     $this->sendPayload();
                 } elseif (!$this->response && $hasPayload) {
                     // back compatibility for use terminate() instead of sendPayload()
                     $this->sendPayload();
                 }
             } catch (Application\AbortException $e) {
             }
         }
         if ($this->hasFlashSession()) {
             $this->getFlashSession()->setExpiration($this->response instanceof Responses\RedirectResponse ? '+ 30 seconds' : '+ 3 seconds');
         }
         // SHUTDOWN
         $this->onShutdown($this, $this->response);
         $this->shutdown($this->response);
         return $this->response;
     }
 }
开发者ID:pdostal,项目名称:nette-blog,代码行数:73,代码来源:Presenter.php

示例6: run

 /**
  * Dispatch a HTTP request to a front controller.
  *
  * @return void
  */
 public function run()
 {
     $request = null;
     $repeatedError = false;
     do {
         try {
             if (count($this->requests) > self::$maxLoop) {
                 throw new ApplicationException('Too many loops detected in application life cycle.');
             }
             if (!$request) {
                 $this->onStartup($this);
                 $request = $this->router->match($this->httpRequest);
                 if (!$request instanceof Request) {
                     $request = null;
                     throw new BadRequestException('No route for HTTP request.');
                 }
                 if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
                     throw new BadRequestException('Invalid request. Presenter is not achievable.');
                 }
             }
             $this->requests[] = $request;
             $this->onRequest($this, $request);
             // Instantiate presenter
             $presenterName = $request->getPresenterName();
             try {
                 $this->presenter = $this->presenterFactory->createPresenter($presenterName);
             } catch (InvalidPresenterException $e) {
                 throw new BadRequestException($e->getMessage(), 404, $e);
             }
             $this->presenterFactory->getPresenterClass($presenterName);
             $request->setPresenterName($presenterName);
             $request->freeze();
             // Execute presenter
             $response = $this->presenter->run($request);
             if ($response) {
                 $this->onResponse($this, $response);
             }
             // Send response
             if ($response instanceof Responses\ForwardResponse) {
                 $request = $response->getRequest();
                 continue;
             } elseif ($response instanceof IResponse) {
                 $response->send($this->httpRequest, $this->httpResponse);
             }
             break;
         } catch (\Exception $e) {
             // fault barrier
             $this->onError($this, $e);
             if (!$this->catchExceptions) {
                 $this->onShutdown($this, $e);
                 throw $e;
             }
             if ($repeatedError) {
                 $e = new ApplicationException('An error occurred while executing error-presenter', 0, $e);
             }
             if (!$this->httpResponse->isSent()) {
                 $this->httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
             }
             if (!$repeatedError && $this->errorPresenter) {
                 $repeatedError = true;
                 if ($this->presenter instanceof UI\Presenter) {
                     try {
                         $this->presenter->forward(":{$this->errorPresenter}:", array('exception' => $e));
                     } catch (AbortException $foo) {
                         $request = $this->presenter->getLastCreatedRequest();
                     }
                 } else {
                     $request = new Request($this->errorPresenter, Request::FORWARD, array('exception' => $e));
                 }
                 // continue
             } else {
                 // default error handler
                 if ($e instanceof BadRequestException) {
                     $code = $e->getCode();
                 } else {
                     $code = 500;
                     Nette\Diagnostics\Debugger::log($e, Nette\Diagnostics\Debugger::ERROR);
                 }
                 require __DIR__ . '/templates/error.phtml';
                 break;
             }
         }
     } while (1);
     $this->onShutdown($this, isset($e) ? $e : null);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:90,代码来源:Application.php

示例7: run

 /**
  * Dispatch a HTTP request to a front controller.
  * @return void
  */
 public function run()
 {
     $request = NULL;
     $repeatedError = FALSE;
     do {
         try {
             if (count($this->requests) > self::$maxLoop) {
                 throw new ApplicationException('Too many loops detected in application life cycle.');
             }
             if (!$request) {
                 $this->onStartup($this);
                 $request = $this->router->match($this->httpRequest);
                 if (!$request instanceof Request) {
                     $request = NULL;
                     throw new BadRequestException('No route for HTTP request.');
                 }
                 if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
                     throw new BadRequestException('Invalid request. Presenter is not achievable.');
                 }
             }
             $this->requests[] = $request;
             $this->onRequest($this, $request);
             // Instantiate presenter
             $presenterName = $request->getPresenterName();
             try {
                 $this->presenter = $this->presenterFactory->createPresenter($presenterName);
             } catch (InvalidPresenterException $e) {
                 throw new BadRequestException($e->getMessage(), 404, $e);
             }
             $this->presenterFactory->getPresenterClass($presenterName);
             $request->setPresenterName($presenterName);
             $request->freeze();
             // Execute presenter
             $response = $this->presenter->run($request);
             if ($response) {
                 $this->onResponse($this, $response);
             }
             // Send response
             if ($response instanceof Responses\ForwardResponse) {
                 $request = $response->getRequest();
                 continue;
             } elseif ($response instanceof IResponse) {
                 $response->send($this->httpRequest, $this->httpResponse);
             }
             break;
         } catch (\Exception $e) {
             $this->onError($this, $e);
             if ($repeatedError) {
                 $e = new ApplicationException("An error occurred while executing error-presenter '{$this->errorPresenter}'.", 0, $e);
             }
             if ($repeatedError || !$this->catchExceptions) {
                 $this->onShutdown($this, $e);
                 throw $e;
             }
             $repeatedError = TRUE;
             $this->errorPresenter = $this->errorPresenter ?: 'Nette:Error';
             if (!$this->httpResponse->isSent()) {
                 $this->httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
             }
             if ($this->presenter instanceof UI\Presenter) {
                 try {
                     $this->presenter->forward(":{$this->errorPresenter}:", array('exception' => $e));
                 } catch (AbortException $foo) {
                     $request = $this->presenter->getLastCreatedRequest();
                 }
             } else {
                 $request = new Request($this->errorPresenter, Request::FORWARD, array('exception' => $e));
             }
             // continue
         }
     } while (1);
     $this->onShutdown($this, isset($e) ? $e : NULL);
 }
开发者ID:radeksimko,项目名称:nette,代码行数:77,代码来源:Application.php


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