Permalink
Browse files

Made it slightly neater

  • Loading branch information...
1 parent d40452b commit 7205f5ec9c6256f4f52fc1d3d87dc6ccaa105af1 Mike Gibson committed Mar 10, 2014
Showing with 14 additions and 14 deletions.
  1. +14 −14 lib/Cake/Routing/Route/CakeRoute.php
@@ -517,28 +517,28 @@ protected function _writeUrl($params) {
}
$out = $this->template;
- $search = $replace = array();
+ if(!empty($this->keys)) {
+
+ $search = $replace = array();
- if(empty($this->keys)) {
- $keys = array();
- } else {
$lengths = array_map('strlen', $this->keys);
$flipped = array_combine($this->keys, $lengths);
arsort($flipped);
$keys = array_keys($flipped);
- }
- foreach ($keys as $key) {
- $string = null;
- if (isset($params[$key])) {
- $string = $params[$key];
- } elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
- $key .= '/';
+ foreach ($keys as $key) {
+ $string = null;
+ if (isset($params[$key])) {
+ $string = $params[$key];
+ } elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
+ $key .= '/';
+ }
+ $search[] = ':' . $key;
+ $replace[] = $string;
}
- $search[] = ':' . $key;
- $replace[] = $string;
+ $out = str_replace($search, $replace, $out);
+
}
- $out = str_replace($search, $replace, $out);
if (strpos($this->template, '*')) {
$out = str_replace('*', $params['pass'], $out);

0 comments on commit 7205f5e

Please sign in to comment.