本文整理汇总了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.');
});
}
}
示例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']);
}
}
}
示例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']);
}
}
示例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));
}
}
示例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']);
}
}
示例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']);
}
}