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


PHP Application::routes方法代码示例

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


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

示例1: onRequest

 /**
  * Registers node routes
  */
 public function onRequest()
 {
     $site = App::module('system/site');
     $frontpage = $site->config('frontpage');
     $nodes = Node::findAll(true);
     uasort($nodes, function ($a, $b) {
         return strcmp(substr_count($a->path, '/'), substr_count($b->path, '/')) * -1;
     });
     foreach ($nodes as $node) {
         if ($node->status !== 1 || !($type = $site->getType($node->type))) {
             continue;
         }
         $type = array_replace(['alias' => '', 'redirect' => '', 'controller' => ''], $type);
         $type['defaults'] = array_merge(isset($type['defaults']) ? $type['defaults'] : [], $node->get('defaults', []), ['_node' => $node->id]);
         $type['path'] = $node->path;
         $route = null;
         if ($node->get('alias')) {
             App::routes()->alias($node->path, $node->link, $type['defaults']);
         } elseif ($node->get('redirect')) {
             App::routes()->redirect($node->path, $node->get('redirect'), $type['defaults']);
         } elseif ($type['controller']) {
             App::routes()->add($type);
         }
         if (!$frontpage && isset($type['frontpage']) && $type['frontpage']) {
             $frontpage = $node->id;
         }
     }
     if ($frontpage && isset($nodes[$frontpage])) {
         App::routes()->alias('/', $nodes[$frontpage]->link);
     } else {
         App::routes()->get('/', function () {
             return __('No Frontpage assigned.');
         });
     }
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:38,代码来源:NodesListener.php

示例2: onConfigureRoute

 /**
  * Registers permalink route alias.
  */
 public function onConfigureRoute($event, $route)
 {
     if ($route->getName() == '@userprofile/profiles/id') {
         App::routes()->alias(dirname($route->getPath()) . '/{slug}', '@userprofile/profiles/id', ['_resolver' => 'Bixie\\Userprofile\\UrlResolver']);
     }
     $name = $route->getName();
     foreach ($this->nodes as $node) {
         if ($name == "@userprofile/profiles/{$node->slug}/id") {
             App::routes()->alias(dirname($route->getPath()) . '/{slug}', "@userprofile/profiles/{$node->slug}/id", ['_resolver' => 'Bixie\\Userprofile\\UrlResolver']);
         }
     }
 }
开发者ID:Bixie,项目名称:pagekit-userprofile,代码行数:15,代码来源:RouteListener.php

示例3: onConfigureRoute

 /**
  * Registers permalink route alias.
  */
 public function onConfigureRoute($event, $route)
 {
     $name = $route->getName();
     if ($name == '@download/id') {
         App::routes()->alias(dirname($route->getPath()) . '/{slug}', '@download/id', ['_resolver' => 'Bixie\\Download\\FileUrlResolver']);
     }
     if (stripos($name, '@download/category/file/') === 0) {
         App::routes()->alias($route->getPath() . '/{slug}', $name, ['_resolver' => 'Bixie\\Download\\FileUrlResolver']);
     }
     if ($name == '@download/file/id') {
         App::routes()->alias(dirname($route->getPath()) . '/{slug}', '@download/file/id', ['_resolver' => 'Bixie\\Download\\FileUrlResolver']);
     }
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:16,代码来源:RouteListener.php

示例4: onRequest

 /**
  * Registers category routes
  */
 public function onRequest()
 {
     $categories = Category::findAll(true);
     uasort($categories, function ($a, $b) {
         return strcmp(substr_count($a->path, '/'), substr_count($b->path, '/')) * -1;
     });
     $node = Node::query()->where(['link' => '@download'])->first();
     foreach ($categories as $category) {
         if ($category->status !== 1) {
             continue;
         }
         $route = ['label' => $category->title, 'defaults' => ['_node' => $node->id, 'id' => $category->id], 'path' => $node->path . $category->path];
         //category views
         App::routes()->add(array_merge(['name' => '@download/category/' . $category->id, 'controller' => 'Bixie\\Download\\Controller\\SiteController::categoryAction'], $route));
         //file view
         App::routes()->add(array_merge(['name' => '@download/category/file/' . $category->id, 'controller' => 'Bixie\\Download\\Controller\\SiteController::fileAction'], $route));
     }
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:21,代码来源:CategoryListener.php

示例5: onConfigureRoute

 /**
  * Registers permalink route alias.
  */
 public function onConfigureRoute($event, $route)
 {
     if ($route->getName() == '@portfolio/id') {
         App::routes()->alias(dirname($route->getPath()) . '/{slug}', '@portfolio/id', ['_resolver' => 'Bixie\\Portfolio\\UrlResolver']);
     }
 }
开发者ID:4nxiety,项目名称:pagekit-portfolio,代码行数:9,代码来源:RouteListener.php

示例6: onConfigureRoute

 /**
  * Registers permalink route alias.
  */
 public function onConfigureRoute($event, $route)
 {
     if ($route->getName() == '@blog/id' && UrlResolver::getPermalink()) {
         App::routes()->alias(dirname($route->getPath()) . '/' . ltrim(UrlResolver::getPermalink(), '/'), '@blog/id', ['_resolver' => 'Pagekit\\Blog\\UrlResolver']);
     }
 }
开发者ID:vanclist,项目名称:spatoday,代码行数:9,代码来源:RouteListener.php


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