pictcode / lib / Cake / Config / routes.php @ 9ddbf630
履歴 | 表示 | アノテート | ダウンロード (3.255 KB)
| 1 |
<?php
|
|---|---|
| 2 |
/**
|
| 3 |
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
| 4 |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
| 5 |
*
|
| 6 |
* Licensed under The MIT License
|
| 7 |
* For full copyright and license information, please see the LICENSE.txt
|
| 8 |
* Redistributions of files must retain the above copyright notice.
|
| 9 |
*
|
| 10 |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
| 11 |
* @link http://cakephp.org CakePHP(tm) Project
|
| 12 |
* @package Cake.Config
|
| 13 |
* @since CakePHP(tm) v 2.0
|
| 14 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
| 15 |
*/
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Connects the default, built-in routes, including prefix and plugin routes. The following routes are created
|
| 19 |
* in the order below:
|
| 20 |
*
|
| 21 |
* For each of the Routing.prefixes the following routes are created. Routes containing `:plugin` are only
|
| 22 |
* created when your application has one or more plugins.
|
| 23 |
*
|
| 24 |
* - `/:prefix/:plugin` a plugin shortcut route.
|
| 25 |
* - `/:prefix/:plugin/:controller`
|
| 26 |
* - `/:prefix/:plugin/:controller/:action/*`
|
| 27 |
* - `/:prefix/:controller`
|
| 28 |
* - `/:prefix/:controller/:action/*`
|
| 29 |
*
|
| 30 |
* If plugins are found in your application the following routes are created:
|
| 31 |
*
|
| 32 |
* - `/:plugin` a plugin shortcut route.
|
| 33 |
* - `/:plugin/:controller`
|
| 34 |
* - `/:plugin/:controller/:action/*`
|
| 35 |
*
|
| 36 |
* And lastly the following catch-all routes are connected.
|
| 37 |
*
|
| 38 |
* - `/:controller'
|
| 39 |
* - `/:controller/:action/*'
|
| 40 |
*
|
| 41 |
* You can disable the connection of default routes by deleting the require inside APP/Config/routes.php.
|
| 42 |
*/
|
| 43 |
$prefixes = Router::prefixes(); |
| 44 |
|
| 45 |
if ($plugins = CakePlugin::loaded()) { |
| 46 |
App::uses('PluginShortRoute', 'Routing/Route'); |
| 47 |
foreach ($plugins as $key => $value) { |
| 48 |
$plugins[$key] = Inflector::underscore($value); |
| 49 |
} |
| 50 |
$pluginPattern = implode('|', $plugins); |
| 51 |
$match = array('plugin' => $pluginPattern, 'defaultRoute' => true); |
| 52 |
$shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern, 'defaultRoute' => true); |
| 53 |
|
| 54 |
foreach ($prefixes as $prefix) { |
| 55 |
$params = array('prefix' => $prefix, $prefix => true); |
| 56 |
$indexParams = $params + array('action' => 'index'); |
| 57 |
Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams); |
| 58 |
Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match); |
| 59 |
Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match); |
| 60 |
} |
| 61 |
Router::connect('/:plugin', array('action' => 'index'), $shortParams); |
| 62 |
Router::connect('/:plugin/:controller', array('action' => 'index'), $match); |
| 63 |
Router::connect('/:plugin/:controller/:action/*', array(), $match); |
| 64 |
} |
| 65 |
|
| 66 |
foreach ($prefixes as $prefix) { |
| 67 |
$params = array('prefix' => $prefix, $prefix => true); |
| 68 |
$indexParams = $params + array('action' => 'index'); |
| 69 |
Router::connect("/{$prefix}/:controller", $indexParams, array('defaultRoute' => true)); |
| 70 |
Router::connect("/{$prefix}/:controller/:action/*", $params, array('defaultRoute' => true)); |
| 71 |
} |
| 72 |
Router::connect('/:controller', array('action' => 'index'), array('defaultRoute' => true)); |
| 73 |
Router::connect('/:controller/:action/*', array(), array('defaultRoute' => true)); |
| 74 |
|
| 75 |
$namedConfig = Router::namedConfig(); |
| 76 |
if ($namedConfig['rules'] === false) { |
| 77 |
Router::connectNamed(true); |
| 78 |
} |
| 79 |
|
| 80 |
unset($namedConfig, $params, $indexParams, $prefix, $prefixes, $shortParams, $match, |
| 81 |
$pluginPattern, $plugins, $key, $value); |
| 82 |
|