當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RedirectResponse::sendHeaders方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\RedirectResponse::sendHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP RedirectResponse::sendHeaders方法的具體用法?PHP RedirectResponse::sendHeaders怎麽用?PHP RedirectResponse::sendHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\RedirectResponse的用法示例。


在下文中一共展示了RedirectResponse::sendHeaders方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: match

 /**
  * Tries to match a URL path with a set of routes.
  *
  * If the matcher can not find information, it must throw one of the
  * exceptions documented below.
  *
  * @param string $pathinfo The path info to be parsed (raw format, i.e. not
  *                         urldecoded)
  *
  * @return array An array of parameters
  *
  * @throws ResourceNotFoundException If the resource could not be found
  * @throws MethodNotAllowedException If the resource was found but the
  *                                   request method is not allowed
  */
 public function match($pathinfo)
 {
     $urlMatcher = new UrlMatcher($this->routeCollection, $this->getContext());
     $result = $urlMatcher->match($pathinfo);
     if (!empty($result)) {
         try {
             // The route matches, now check if it actually exists
             $result['content'] = $this->contentManager->findActiveBySlug($result['slug']);
         } catch (NoResultException $e) {
             try {
                 //is it directory index
                 if (substr($result['slug'], -1) == '/' || $result['slug'] == '') {
                     $result['content'] = $this->contentManager->findActiveBySlug($result['slug'] . 'index');
                 } else {
                     if ($this->contentManager->findActiveBySlug($result['slug'] . '/index')) {
                         $redirect = new RedirectResponse($this->request->getBaseUrl() . "/" . $result['slug'] . '/');
                         $redirect->sendHeaders();
                         exit;
                     }
                 }
             } catch (NoResultException $ex) {
                 try {
                     $result['content'] = $this->contentManager->findActiveByAlias($result['slug']);
                 } catch (NoResultException $ex) {
                     throw new ResourceNotFoundException('No page found for slug ' . $pathinfo);
                 }
             }
         }
     }
     return $result;
 }
開發者ID:dylanschoenmakers,項目名稱:Cms,代碼行數:46,代碼來源:ContentRouter.php

示例2: redirect

 /**
  * Redirect Response.
  *
  * @param string $url
  * @param int    $status
  * @param array  $headers
  */
 public static function redirect($url, $status = 302, $headers = array())
 {
     $redirect = new RedirectResponse($url, $status, $headers);
     $redirect->sendHeaders();
     die;
 }
開發者ID:tonjoo,項目名稱:tiga-framework,代碼行數:13,代碼來源:ResponseFactory.php

示例3: redirect

 /**
  * (non-PHPdoc)
  * @see TheTwelve\Foursquare.Redirector::redirect()
  */
 public function redirect($uri)
 {
     $response = new HttpFoundation\RedirectResponse($uri);
     $response->sendHeaders();
     return $response;
 }
開發者ID:sara62,項目名稱:foursquare-php,代碼行數:10,代碼來源:SymfonyRedirector.php


注:本文中的Symfony\Component\HttpFoundation\RedirectResponse::sendHeaders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。