当前位置: 首页>>代码示例>>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;未经允许,请勿转载。