From ee777e844efeffc4fc0fd638ffb6095c6bd18830 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 27 Apr 2013 22:02:35 -0400 Subject: [PATCH] Support alternative URL rule syntax. --- framework/web/UrlManager.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/framework/web/UrlManager.php b/framework/web/UrlManager.php index 755d644..90a721b 100644 --- a/framework/web/UrlManager.php +++ b/framework/web/UrlManager.php @@ -97,12 +97,20 @@ class UrlManager extends Component } } - foreach ($this->rules as $i => $rule) { - if (!isset($rule['class'])) { + $rules = array(); + foreach ($this->rules as $key => $rule) { + if (!is_array($rule)) { + $rule = array( + 'class' => $this->defaultRuleClass, + 'pattern' => $key, + 'route' => $rule, + ); + } elseif (!isset($rule['class'])) { $rule['class'] = $this->defaultRuleClass; } - $this->rules[$i] = Yii::createObject($rule); + $rules[] = Yii::createObject($rule); } + $this->rules = $rules; if (isset($key, $hash)) { $this->cache->set($key, array($this->rules, $hash));