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


PHP Grav::redirect方法代码示例

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


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

示例1: redirect

 /**
  * Redirects an action
  */
 public function redirect()
 {
     if ($this->redirect) {
         $this->grav->redirect($this->redirect, $this->redirectCode);
     } else {
         if ($redirect = $this->grav['config']->get('plugins.login.redirect')) {
             $this->grav->redirect($redirect, $this->redirectCode);
         }
     }
 }
开发者ID:ulilu,项目名称:grav-toctoc,代码行数:13,代码来源:Controller.php

示例2: dispatch

 /**
  * Dispatch URI to a page.
  *
  * @param $url
  * @param bool $all
  * @return Page|null
  */
 public function dispatch($url, $all = false)
 {
     // Fetch page if there's a defined route to it.
     $page = isset($this->routes[$url]) ? $this->get($this->routes[$url]) : null;
     // If the page cannot be reached, look into site wide redirects, routes + wildcards
     if (!$all && (!$page || !$page->routable())) {
         /** @var Config $config */
         $config = $this->grav['config'];
         // Try redirects
         $redirect = $config->get("site.redirects.{$url}");
         if ($redirect) {
             $this->grav->redirect($redirect);
         }
         // See if route matches one in the site configuration
         $route = $config->get("site.routes.{$url}");
         if ($route) {
             $page = $this->dispatch($route, $all);
         } else {
             // Try looking for wildcards
             foreach ($config->get("site.routes") as $alias => $route) {
                 $match = rtrim($alias, '*');
                 if (strpos($alias, '*') !== false && strpos($url, $match) !== false) {
                     $wildcard_url = str_replace('*', str_replace($match, '', $url), $route);
                     $page = isset($this->routes[$wildcard_url]) ? $this->get($this->routes[$wildcard_url]) : null;
                     if ($page) {
                         return $page;
                     }
                 }
             }
         }
     }
     return $page;
 }
开发者ID:alexslack,项目名称:faith-game,代码行数:40,代码来源:Pages.php

示例3: redirect

 /**
  * Redirect to the route stored in $this->redirect
  */
 public function redirect()
 {
     if (!$this->redirect) {
         return;
     }
     $base = $this->admin->base;
     $this->redirect = '/' . ltrim($this->redirect, '/');
     $multilang = $this->isMultilang();
     $redirect = '';
     if ($multilang) {
         // if base path does not already contain the lang code, add it
         $langPrefix = '/' . $this->grav['session']->admin_lang;
         if (!Utils::startsWith($base, $langPrefix . '/')) {
             $base = $langPrefix . $base;
         }
         // now the first 4 chars of base contain the lang code.
         // if redirect path already contains the lang code, and is != than the base lang code, then use redirect path as-is
         if (Utils::pathPrefixedByLangCode($base) && Utils::pathPrefixedByLangCode($this->redirect) && substr($base, 0, 4) != substr($this->redirect, 0, 4)) {
             $redirect = $this->redirect;
         } else {
             if (!Utils::startsWith($this->redirect, $base)) {
                 $this->redirect = $base . $this->redirect;
             }
         }
     } else {
         if (!Utils::startsWith($this->redirect, $base)) {
             $this->redirect = $base . $this->redirect;
         }
     }
     if (!$redirect) {
         $redirect = $this->redirect;
     }
     $this->grav->redirect($redirect, $this->redirectCode);
 }
开发者ID:clee03,项目名称:metal,代码行数:37,代码来源:controller.php

示例4: redirect

 /**
  * Redirect to the route stored in $this->redirect
  */
 public function redirect()
 {
     if (!$this->redirect) {
         return;
     }
     $base = $this->admin->base;
     $path = trim(substr($this->redirect, 0, strlen($base)) == $base ? substr($this->redirect, strlen($base)) : $this->redirect, '/');
     $this->grav->redirect($base . '/' . preg_replace('|/+|', '/', $path), $this->redirectCode);
 }
开发者ID:spiridonovn,项目名称:grav-plugin-admin,代码行数:12,代码来源:controller.php

示例5: redirect

 /**
  * Redirects an action
  */
 public function redirect()
 {
     $redirect = $this->grav['config']->get('plugins.newsletter.admin.subscriber.enable.redirect');
     if (!$redirect) {
         $this->grav->redirect($redirect, $this->redirectCode);
     } else {
         if ($this->redirect) {
             $this->grav->redirect($this->redirect, $this->redirectCode);
         }
     }
 }
开发者ID:mcspronko,项目名称:grav-plugin-newsletter,代码行数:14,代码来源:SubscriberController.php

示例6: dispatch

 /**
  * Dispatch URI to a page.
  *
  * @param $url
  * @param bool $all
  * @return Page|null
  */
 public function dispatch($url, $all = false)
 {
     // Fetch page if there's a defined route to it.
     $page = isset($this->routes[$url]) ? $this->get($this->routes[$url]) : null;
     // If the page cannot be reached, look into site wide redirects, routes + wildcards
     if (!$all && (!$page || !$page->routable())) {
         /** @var Config $config */
         $config = $this->grav['config'];
         // See if route matches one in the site configuration
         $route = $config->get("site.routes.{$url}");
         if ($route) {
             $page = $this->dispatch($route, $all);
         } else {
             // Try Regex style redirects
             foreach ((array) $config->get("site.redirects") as $pattern => $replace) {
                 $pattern = '#' . $pattern . '#';
                 try {
                     $found = preg_replace($pattern, $replace, $url);
                     if ($found != $url) {
                         $this->grav->redirect($found);
                     }
                 } catch (ErrorException $e) {
                     $this->grav['log']->error('site.redirects: ' . $pattern . '-> ' . $e->getMessage());
                 }
             }
             // Try Regex style routes
             foreach ((array) $config->get("site.routes") as $pattern => $replace) {
                 $pattern = '#' . $pattern . '#';
                 try {
                     $found = preg_replace($pattern, $replace, $url);
                     if ($found != $url) {
                         $page = $this->dispatch($found, $all);
                     }
                 } catch (ErrorException $e) {
                     $this->grav['log']->error('site.routes: ' . $pattern . '-> ' . $e->getMessage());
                 }
             }
         }
     }
     return $page;
 }
开发者ID:re-pe,项目名称:grav,代码行数:48,代码来源:Pages.php

示例7: redirect

 /**
  * Redirects an action
  */
 public function redirect()
 {
     if ($this->redirect) {
         $this->grav->redirect($this->redirect, $this->redirectCode);
     }
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:9,代码来源:Controller.php


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