mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 03:22:39 +00:00
Merge remote branch 'origin/2.0' into 2.0-class-loading
Conflicts: cake/libs/view/scaffolds/edit.ctp cake/libs/view/scaffolds/form.ctp cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.edit.ctp cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.form.ctp cake/tests/test_app/views/posts/scaffold.edit.ctp cake/tests/test_app/views/posts/scaffold.form.ctp lib/Cake/Error/ErrorHandler.php lib/Cake/Model/Behavior/TranslateBehavior.php lib/Cake/Model/Datasource/CakeSession.php lib/Cake/Routing/Router.php lib/Cake/TestSuite/TestManager.php lib/Cake/View/scaffolds/edit.ctp lib/Cake/tests/cases/console/shells/bake.test.php lib/Cake/tests/cases/libs/cake_log.test.php lib/Cake/tests/cases/libs/cake_request.test.php lib/Cake/tests/cases/libs/view/helpers/number.test.php lib/Cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.edit.ctp lib/Cake/tests/test_app/views/posts/scaffold.edit.ctp
This commit is contained in:
commit
07e43bb0f8
122 changed files with 4822 additions and 2612 deletions
|
@ -226,7 +226,7 @@ class Router {
|
|||
* shifted into the passed arguments. As well as supplying patterns for routing parameters.
|
||||
* @see routes
|
||||
* @return array Array of routes
|
||||
* @throws Exception
|
||||
* @throws RouterException
|
||||
*/
|
||||
public static function connect($route, $defaults = array(), $options = array()) {
|
||||
foreach (self::$_prefixes as $prefix) {
|
||||
|
@ -246,13 +246,15 @@ class Router {
|
|||
$routeClass = 'CakeRoute';
|
||||
if (isset($options['routeClass'])) {
|
||||
$routeClass = $options['routeClass'];
|
||||
if (!is_subclass_of($routeClass, 'CakeRoute')) {
|
||||
throw new RouterException(__('Route classes must extend CakeRoute'));
|
||||
}
|
||||
unset($options['routeClass']);
|
||||
if ($routeClass == 'RedirectRoute' && isset($defaults['redirect'])) {
|
||||
$defaults = $defaults['redirect'];
|
||||
}
|
||||
}
|
||||
$Route = new $routeClass($route, $defaults, $options);
|
||||
if (!$Route instanceof CakeRoute) {
|
||||
throw new Exception(__('Route classes must extend CakeRoute'));
|
||||
}
|
||||
self::$routes[] =& $Route;
|
||||
self::$routes[] = new $routeClass($route, $defaults, $options);
|
||||
return self::$routes;
|
||||
}
|
||||
|
||||
|
@ -285,9 +287,12 @@ class Router {
|
|||
* @see routes
|
||||
* @return array Array of routes
|
||||
*/
|
||||
public static function redirect($route, $url, $options) {
|
||||
public static function redirect($route, $url, $options = array()) {
|
||||
App::uses('RedirectRoute', 'Routing/Route');
|
||||
$options['routeClass'] = 'RedirectRoute';
|
||||
if (is_string($url)) {
|
||||
$url = array('redirect' => $url);
|
||||
}
|
||||
return self::connect($route, $url, $options);
|
||||
}
|
||||
|
||||
|
@ -938,8 +943,15 @@ class Router {
|
|||
}
|
||||
|
||||
if (!empty($named)) {
|
||||
foreach ($named as $name => $value) {
|
||||
$output .= '/' . $name . self::$named['separator'] . $value;
|
||||
foreach ($named as $name => $value) {
|
||||
if (is_array($value)) {
|
||||
$flattend = Set::flatten($value, '][');
|
||||
foreach ($flattend as $namedKey => $namedValue) {
|
||||
$output .= '/' . $name . "[$namedKey]" . self::$named['separator'] . $namedValue;
|
||||
}
|
||||
} else {
|
||||
$output .= '/' . $name . self::$named['separator'] . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
|
@ -1203,7 +1215,22 @@ class Router {
|
|||
if ($passIt) {
|
||||
$pass[] = $param;
|
||||
} else {
|
||||
$named[$key] = $val;
|
||||
if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) {
|
||||
$matches = array_reverse($matches);
|
||||
$key = array_shift(explode('[', $key));
|
||||
$arr = $val;
|
||||
foreach ($matches as $match) {
|
||||
if (empty($match[1])) {
|
||||
$arr = array($arr);
|
||||
} else {
|
||||
$arr = array(
|
||||
$match[1] => $arr
|
||||
);
|
||||
}
|
||||
}
|
||||
$val = $arr;
|
||||
}
|
||||
$named = array_merge_recursive($named, array($key => $val));
|
||||
}
|
||||
} else {
|
||||
$pass[] = $param;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue