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


PHP Response::isRedirection方法代码示例

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


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

示例1: after

 public function after(Request $request, Response $response, Application $app)
 {
     if ($response->isRedirection()) {
         return;
     }
     // if ('application/json' === $request->headers->get('Accept')) {
     //     return $this->app()->json($this->data);
     // }
     //https://blog.yorunohikage.fr/
     //Pretty printing all JSON output in Silex PHP
     //if($response instanceof JsonResponse) {
     //    $response->setEncodingOptions(JSON_PRETTY_PRINT);
     //}
     if ($request->isXmlHttpRequest()) {
         $response_data = array('status' => 'OK', 'data' => $this->data);
         if (!is_null($this->error)) {
             $response_data['status'] = 'ERROR';
             $response_data['error'] = $this->error;
         }
         return $this->app->json($response_data);
     }
     if ($response->getContent() == '') {
         $this->initTwig();
         $response->setContent($this->twig()->render($this->template, $this->data));
     }
 }
开发者ID:EvilKraft,项目名称:silex-skeletion,代码行数:26,代码来源:Controller.php

示例2: injectJavascript

 public static function injectJavascript(Response $response)
 {
     if (app()->runningInConsole() || !self::isActive() || $response->isRedirection() || !config('2checkout.inject')) {
         return $response;
     }
     $content = $response->getContent();
     $response->setContent(str_replace("</body>", "<script src='https://www.2checkout.com/checkout/api/2co.min.js'></script>\n</body>", $content));
     return $response;
 }
开发者ID:arleslie,项目名称:2checkout,代码行数:9,代码来源:Base.php

示例3: getParameters

 /**
  * {@inheritdoc}
  */
 public function getParameters()
 {
     $code = null;
     $codeType = null;
     $cacheable = null;
     if (null !== $this->response) {
         $code = sprintf('%d', $this->response->getStatusCode());
         $cacheable = $this->response->isCacheable() ? 'cacheable' : 'not_cacheable';
         if ($this->response->isInformational()) {
             $codeType = 'informational';
         } elseif ($this->response->isSuccessful()) {
             $codeType = 'successful';
         } elseif ($this->response->isRedirection()) {
             $codeType = 'redirection';
         } elseif ($this->response->isClientError()) {
             $codeType = 'client_error';
         } elseif ($this->response->isServerError()) {
             $codeType = 'server_error';
         } else {
             $codeType = 'other';
         }
     }
     return array('response_code' => $code, 'response_code_type' => $codeType, 'response_cacheable' => $cacheable);
 }
开发者ID:adrienbrault,项目名称:statsd-collector,代码行数:27,代码来源:SymfonyResponseProvider.php

示例4: modifyResponse

 /**
  * Modify the response and inject the debugbar (or data in headers)
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Symfony\Component\HttpFoundation\Response  $response
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function modifyResponse($request, $response)
 {
     $app = $this->app;
     if ($app->runningInConsole() or !$this->isEnabled() || $this->isDebugbarRequest()) {
         return $response;
     }
     if ($this->shouldCollect('config', false)) {
         try {
             $configCollector = new ConfigCollector();
             $configCollector->setData($app['config']->getItems());
             $this->addCollector($configCollector);
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     /** @var \Illuminate\Session\SessionManager $sessionManager */
     $sessionManager = $app['session'];
     $httpDriver = new SymfonyHttpDriver($sessionManager, $response);
     $this->setHttpDriver($httpDriver);
     if ($this->shouldCollect('symfony_request', true) and !$this->hasCollector('request')) {
         try {
             $this->addCollector(new SymfonyRequestCollector($request, $response, $sessionManager));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($response->isRedirection()) {
         try {
             $this->stackData();
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($request->isXmlHttpRequest() || $request->wantsJson() and $app['config']->get('laravel-debugbar::config.capture_ajax', true)) {
         try {
             $this->sendDataInHeaders(true);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html') || 'html' !== $request->format()) {
         //Do nothing
     } elseif ($app['config']->get('laravel-debugbar::config.inject', true)) {
         try {
             $this->injectDebugbar($response);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     }
     // Stop further rendering (on subrequests etc)
     $this->disable();
     return $response;
 }
开发者ID:cenwj,项目名称:sns,代码行数:58,代码来源:LaravelDebugBar.php

示例5: deny

 /**
  * deny.
  *
  * @method deny
  *
  * @param  \Symfony\Component\HttpFoundation\Response $response
  * @param  int                                        $statusCode
  *
  * @return bool
  */
 protected function deny(Response $response, $statusCode)
 {
     if ($response instanceof BinaryFileResponse) {
         return true;
     }
     if ($response instanceof StreamedResponse) {
         return true;
     }
     if ($response->isRedirection() === true) {
         return true;
     }
     if ($this->ajax === true) {
         return false;
     }
     $contentType = $response->headers->get('Content-Type');
     if (empty($contentType) === true && $statusCode >= 400) {
         return false;
     }
     if (count($this->accepts) === 0) {
         return false;
     }
     $contentType = strtolower($contentType);
     foreach ($this->accepts as $accept) {
         if (strpos($contentType, $accept) !== false) {
             return false;
         }
     }
     return true;
 }
开发者ID:recca0120,项目名称:laravel-tracy,代码行数:39,代码来源:Debugbar.php

示例6: shouldCacheResponse

 /**
  * Determine if the given response should be cached.
  *
  * @param \Symfony\Component\HttpFoundation\Response $response
  *
  * @return bool
  */
 public function shouldCacheResponse(Response $response)
 {
     return $response->isSuccessful() || $response->isRedirection();
 }
开发者ID:zedx,项目名称:core,代码行数:11,代码来源:CacheProfile.php

示例7: testIsRedirectRedirection

 public function testIsRedirectRedirection()
 {
     foreach (array(301, 302, 303, 307) as $code) {
         $response = new Response('', $code);
         $this->assertTrue($response->isRedirection());
         $this->assertTrue($response->isRedirect());
     }
     $response = new Response('', 304);
     $this->assertTrue($response->isRedirection());
     $this->assertFalse($response->isRedirect());
     $response = new Response('', 200);
     $this->assertFalse($response->isRedirection());
     $this->assertFalse($response->isRedirect());
     $response = new Response('', 404);
     $this->assertFalse($response->isRedirection());
     $this->assertFalse($response->isRedirect());
     $response = new Response('', 301, array('Location' => '/good-uri'));
     $this->assertFalse($response->isRedirect('/bad-uri'));
     $this->assertTrue($response->isRedirect('/good-uri'));
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:20,代码来源:ResponseTest.php

示例8: collect

 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     // Sub-requests and programmatic calls stay in the collected profile.
     if ($this->dumper || $this->requestStack && $this->requestStack->getMasterRequest() !== $request || $request->isXmlHttpRequest() || $request->headers->has('Origin')) {
         return;
     }
     // In all other conditions that remove the web debug toolbar, dumps are written on the output.
     if (!$this->requestStack || !$response->headers->has('X-Debug-Token') || $response->isRedirection() || $response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html') || 'html' !== $request->getRequestFormat() || false === strripos($response->getContent(), '</body>')) {
         if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) {
             $this->dumper = new HtmlDumper('php://output', $this->charset);
         } else {
             $this->dumper = new CliDumper('php://output', $this->charset);
         }
         foreach ($this->data as $dump) {
             $this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']);
         }
     }
 }
开发者ID:GeorgeShazkho,项目名称:micros-de-conce,代码行数:18,代码来源:DumpDataCollector.php

示例9: modifyResponse

 /**
  * Modify the response and inject the debugbar (or data in headers)
  *
  * @param  \Symfony\Component\HttpFoundation\Request $request
  * @param  \Symfony\Component\HttpFoundation\Response $response
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function modifyResponse($request, $response)
 {
     $app = $this->app;
     if ($app->runningInConsole() || !$this->isEnabled() || $this->isDebugbarRequest()) {
         return $response;
     }
     if ($this->shouldCollect('config', false)) {
         try {
             $configCollector = new ConfigCollector();
             $configCollector->setData($app['config']->all());
             $this->addCollector($configCollector);
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     /** @var \Illuminate\Session\SessionManager $sessionManager */
     $sessionManager = $app['session'];
     $httpDriver = new SymfonyHttpDriver($sessionManager, $response);
     $this->setHttpDriver($httpDriver);
     if ($this->shouldCollect('session')) {
         try {
             $this->addCollector(new SessionCollector($sessionManager));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($this->shouldCollect('symfony_request', true) && !$this->hasCollector('request')) {
         try {
             $this->addCollector(new SymfonyRequestCollector($request, $response, $sessionManager));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($response->isRedirection()) {
         try {
             $this->stackData();
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($this->isJsonRequest($request) && $app['config']->get('debugbar.capture_ajax', true)) {
         try {
             $this->sendDataInHeaders(true);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($response->headers->has('Content-Type') && strpos($response->headers->get('Content-Type'), 'html') === false || $request->getRequestFormat() !== 'html') {
         try {
             // Just collect + store data, don't inject it.
             $this->collect();
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($app['config']->get('debugbar.inject', true)) {
         try {
             $this->injectDebugbar($response);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     }
     // Stop further rendering (on subrequests etc)
     $this->disable();
     return $response;
 }
开发者ID:pavankumarkatakam,项目名称:laravel-debugbar,代码行数:70,代码来源:LaravelDebugbar.php

示例10: isHtmlResponse

 /**
  * Check if the response is a html page.
  *
  * @param Response $response
  * @return bool
  */
 private function isHtmlResponse(Response $response)
 {
     $headers = $response->headers;
     // assumes responses without Content-Type header are html
     return !$response->isRedirection() && (!$headers->has('Content-Type') || strpos($headers->get('Content-Type'), 'html') !== false);
 }
开发者ID:bravesheep,项目名称:live-reload-bundle,代码行数:12,代码来源:ScriptInjectorSubscriber.php

示例11: assertRedirectedResponse

 public function assertRedirectedResponse(Response $response)
 {
     $this->assertTrue($response->isRedirection());
 }
开发者ID:eugene-matvejev,项目名称:battleship-game-api,代码行数:4,代码来源:ResponseAssertionSuites.php


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