Commit 1170e027 by Alexander Makarov

Merge branch 'master'

Conflicts: framework/CHANGELOG.md
parents 178417da 9470faf2
...@@ -6,6 +6,8 @@ if (!YII_ENV_TEST) { ...@@ -6,6 +6,8 @@ if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment // configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug'; $config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module'; $config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module'; $config['modules']['gii'] = 'yii\gii\Module';
} }
......
...@@ -6,6 +6,8 @@ if (!YII_ENV_TEST) { ...@@ -6,6 +6,8 @@ if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment // configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug'; $config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module'; $config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module'; $config['modules']['gii'] = 'yii\gii\Module';
} }
......
...@@ -41,6 +41,8 @@ if (YII_ENV_DEV) { ...@@ -41,6 +41,8 @@ if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment // configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug'; $config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module'; $config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module'; $config['modules']['gii'] = 'yii\gii\Module';
} }
......
...@@ -15,7 +15,7 @@ automatically degrade to normal page requests and are still functioning as expec ...@@ -15,7 +15,7 @@ automatically degrade to normal page requests and are still functioning as expec
The minimal code needed to use GridView is as follows: The minimal code needed to use GridView is as follows:
```php ```php
use yii\data\GridView; use yii\grid\GridView;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
......
...@@ -8,7 +8,7 @@ as well as complete CRUD controllers. ...@@ -8,7 +8,7 @@ as well as complete CRUD controllers.
Installing and configuring Installing and configuring
-------------------------- --------------------------
Gii is an offical Yii extension. The preferred way to install this extension is through Gii is an official Yii extension. The preferred way to install this extension is through
[composer](http://getcomposer.org/download/). [composer](http://getcomposer.org/download/).
You can either run this command: You can either run this command:
...@@ -26,11 +26,14 @@ Or you can add this code to the require section of your `composer.json` file: ...@@ -26,11 +26,14 @@ Or you can add this code to the require section of your `composer.json` file:
Once the Gii extension has been installed, you enable it by adding these lines to your application configuration file: Once the Gii extension has been installed, you enable it by adding these lines to your application configuration file:
```php ```php
'modules' => [ return [
'gii' => [ 'bootstrap' => ['gii'],
'class' => 'yii\gii\Module', 'modules' => [
'gii' => 'yii\gii\Module',
// ...
], ],
] // ...
];
``` ```
You can then access Gii through the following URL: You can then access Gii through the following URL:
...@@ -39,7 +42,15 @@ You can then access Gii through the following URL: ...@@ -39,7 +42,15 @@ You can then access Gii through the following URL:
http://localhost/path/to/index.php?r=gii http://localhost/path/to/index.php?r=gii
``` ```
> Note: if you are accessing gii from an IP address other than localhost, access will be denied by default. To circumvent that default, add the allowed IP addressess to the configuration: If you have enabled pretty URLs, you may use the following URL:
```
http://localhost/path/to/index.php/gii
```
> Note: if you are accessing gii from an IP address other than localhost, access will be denied by default.
> To circumvent that default, add the allowed IP addresses to the configuration:
> >
```php ```php
'gii' => [ 'gii' => [
...@@ -55,11 +66,12 @@ In basic application template configuration structure is a bit different so Gii ...@@ -55,11 +66,12 @@ In basic application template configuration structure is a bit different so Gii
```php ```php
// ... // ...
if (YII_ENV_DEV) if (YII_ENV_DEV) {
{
// configuration adjustments for 'dev' environment // configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug'; $config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module'; $config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module'; // <--- here $config['modules']['gii'] = 'yii\gii\Module'; // <--- here
} }
``` ```
...@@ -67,11 +79,12 @@ if (YII_ENV_DEV) ...@@ -67,11 +79,12 @@ if (YII_ENV_DEV)
So in order to adjust IP address you need to do it like the following: So in order to adjust IP address you need to do it like the following:
```php ```php
if (YII_ENV_DEV) if (YII_ENV_DEV) {
{
// configuration adjustments for 'dev' environment // configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug'; $config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module'; $config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [ $config['modules']['gii'] = [
'class' => 'yii\gii\Module', 'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
...@@ -100,8 +113,8 @@ By default there are the following generators available: ...@@ -100,8 +113,8 @@ By default there are the following generators available:
After choosing a generator by clicking on the "Start" button you will see a form that allows you to configure the After choosing a generator by clicking on the "Start" button you will see a form that allows you to configure the
parameters of the generator. Fill out the form according to your needs and press the "Preview" button to get a parameters of the generator. Fill out the form according to your needs and press the "Preview" button to get a
preview of the code that gii is about to generated. Dependend on the generator you chose and whether the files preview of the code that gii is about to generated. Depending on the generator you chose and whether the files
already existed or not you will get an ouput similar to what you see in the following picuture: already existed or not, you will get an output similar to what you see in the following picture:
![Gii preview](images/gii-preview.png) ![Gii preview](images/gii-preview.png)
...@@ -143,7 +156,9 @@ If you open a folder `@app\vendor\yiisoft\yii2-gii\generators`, you'll see six f ...@@ -143,7 +156,9 @@ If you open a folder `@app\vendor\yiisoft\yii2-gii\generators`, you'll see six f
``` ```
This is name generator. If you open any of these folders, you can see the folder `default`. This folder is name of the template. This is name generator. If you open any of these folders, you can see the folder `default`. This folder is name of the template.
Copy folder `@app\vendor\yiisoft\yii2-gii\generators\crud\default` to another location, for example `@app\myTemplates\crud\`. Now open this folder and modify any template to fit your desires, for example, add `errorSummary` in `views\_form.php`: Copy folder `@app\vendor\yiisoft\yii2-gii\generators\crud\default` to another location, for example `@app\myTemplates\crud\`.
Now open this folder and modify any template to fit your desires, for example, add `errorSummary` in `views\_form.php`:
```php ```php
<?php <?php
//... //...
...@@ -156,19 +171,21 @@ Copy folder `@app\vendor\yiisoft\yii2-gii\generators\crud\default` to another lo ...@@ -156,19 +171,21 @@ Copy folder `@app\vendor\yiisoft\yii2-gii\generators\crud\default` to another lo
} ?> } ?>
//... //...
``` ```
All, in fact our template ready. Now you need to tell GII about our template.The setting is made in the config file:
Now you need to tell GII about our template.The setting is made in the config file:
```php ```php
//config/web.php for basic app // config/web.php for basic app
//.. // ...
if (YII_ENV_DEV) { if (YII_ENV_DEV) {
$config['modules']['gii'] = [ $config['modules']['gii'] = [
'class' => 'yii\gii\Module', 'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
'generators'=>[ //here 'generators' => [ //here
'crud'=>[ //name generator 'crud' => [ //name generator
'class'=>'yii\gii\generators\crud\Generator', //class generator 'class' => 'yii\gii\generators\crud\Generator', //class generator
'templates'=>[ //setting for out tempates 'templates' => [ //setting for out templates
'myCrud'=>'@app\myTemplates\crud\default', //name tempate => path to template 'myCrud' => '@app\myTemplates\crud\default', //name template => path to template
] ]
] ]
], ],
...@@ -180,7 +197,10 @@ Open the CRUD generator and you will see that in the field `Code Template` of fo ...@@ -180,7 +197,10 @@ Open the CRUD generator and you will see that in the field `Code Template` of fo
Creating your own generators Creating your own generators
---------------------------- ----------------------------
Open the folder of any generator and you will see two files `form.php` and `Generator.php`. One is the form, the second is the class generator. For create your own generator, you need to create or override these classes in any folder. Again as in the previous paragraph customize configuration: Open the folder of any generator and you will see two files `form.php` and `Generator.php`.
One is the form, the second is the class generator. For create your own generator, you need to create or
override these classes in any folder. Again as in the previous paragraph customize configuration:
```php ```php
//config/web.php for basic app //config/web.php for basic app
//.. //..
...@@ -188,11 +208,11 @@ if (YII_ENV_DEV) { ...@@ -188,11 +208,11 @@ if (YII_ENV_DEV) {
$config['modules']['gii'] = [ $config['modules']['gii'] = [
'class' => 'yii\gii\Module', 'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'], 'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
'generators'=>[ 'generators' => [
'myCrud'=>[ 'myCrud' => [
'class'=>'app\myTemplates\crud\Generator', 'class' => 'app\myTemplates\crud\Generator',
'templates'=>[ 'templates' => [
'my'=>'@app/myTemplates/crud/default', 'my' => '@app/myTemplates/crud/default',
] ]
] ]
], ],
...@@ -204,6 +224,7 @@ if (YII_ENV_DEV) { ...@@ -204,6 +224,7 @@ if (YII_ENV_DEV) {
// @app/myTemplates/crud/Generator.php // @app/myTemplates/crud/Generator.php
<?php <?php
namespace app\myTemplates\crud; namespace app\myTemplates\crud;
class Generator extends \yii\gii\Generator class Generator extends \yii\gii\Generator
{ {
public function getName() public function getName()
...@@ -218,7 +239,7 @@ class Generator extends \yii\gii\Generator ...@@ -218,7 +239,7 @@ class Generator extends \yii\gii\Generator
// ... // ...
} }
``` ```
Open gii Module and You will see that added a new generator.
Open Gii Module and you will see a new generator appears in it.
...@@ -4,6 +4,7 @@ Yii Framework 2 debug extension Change Log ...@@ -4,6 +4,7 @@ Yii Framework 2 debug extension Change Log
2.0.0-rc under development 2.0.0-rc under development
-------------------------- --------------------------
- Enh #3088: The debug module will manage their own URL rules now (qiangxue)
- Enh #3103: debugger panel is now not displayed when printing a page (githubjeka) - Enh #3103: debugger panel is now not displayed when printing a page (githubjeka)
- Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue) - Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue)
......
...@@ -117,6 +117,11 @@ class Module extends \yii\base\Module implements BootstrapInterface ...@@ -117,6 +117,11 @@ class Module extends \yii\base\Module implements BootstrapInterface
$app->on(Application::EVENT_BEFORE_REQUEST, function () use ($app) { $app->on(Application::EVENT_BEFORE_REQUEST, function () use ($app) {
$app->getView()->on(View::EVENT_END_BODY, [$this, 'renderToolbar']); $app->getView()->on(View::EVENT_END_BODY, [$this, 'renderToolbar']);
}); });
$app->getUrlManager()->addRules([
$this->id => $this->id,
$this->id . '/<controller:\w+>/<action:\w+>' => $this->id . '/<controller>/<action>',
], false);
} }
/** /**
......
...@@ -33,12 +33,12 @@ Once the extension is installed, simply modify your application configuration as ...@@ -33,12 +33,12 @@ Once the extension is installed, simply modify your application configuration as
```php ```php
return [ return [
'bootstrap' => ['debug'], 'bootstrap' => ['debug'],
'modules' => [ 'modules' => [
'debug' => 'yii\debug\Module', 'debug' => 'yii\debug\Module',
... // ...
], ],
... ...
]; ];
``` ```
......
...@@ -4,7 +4,7 @@ Yii Framework 2 gii extension Change Log ...@@ -4,7 +4,7 @@ Yii Framework 2 gii extension Change Log
2.0.0-rc under development 2.0.0-rc under development
-------------------------- --------------------------
- no changes in this release. - Enh #3088: The gii module will manage their own URL rules now (qiangxue)
2.0.0-beta April 13, 2014 2.0.0-beta April 13, 2014
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace yii\gii; namespace yii\gii;
use Yii; use Yii;
use yii\base\BootstrapInterface;
use yii\web\ForbiddenHttpException; use yii\web\ForbiddenHttpException;
/** /**
...@@ -17,7 +18,7 @@ use yii\web\ForbiddenHttpException; ...@@ -17,7 +18,7 @@ use yii\web\ForbiddenHttpException;
* *
* ~~~ * ~~~
* return [ * return [
* ...... * 'bootstrap' => ['gii'],
* 'modules' => [ * 'modules' => [
* 'gii' => ['class' => 'yii\gii\Module'], * 'gii' => ['class' => 'yii\gii\Module'],
* ], * ],
...@@ -32,26 +33,13 @@ use yii\web\ForbiddenHttpException; ...@@ -32,26 +33,13 @@ use yii\web\ForbiddenHttpException;
* With the above configuration, you will be able to access GiiModule in your browser using * With the above configuration, you will be able to access GiiModule in your browser using
* the URL `http://localhost/path/to/index.php?r=gii` * the URL `http://localhost/path/to/index.php?r=gii`
* *
* If your application enables [[\yii\web\UrlManager::enablePrettyUrl|pretty URLs]] and you have defined * If your application enables [[\yii\web\UrlManager::enablePrettyUrl|pretty URLs]],
* custom URL rules or enabled [[\yii\web\UrlManager::enableStrictParsing], you may need to add * you can then access Gii via URL: `http://localhost/path/to/index.php/gii`
* the following URL rules at the beginning of your URL rule set in your application configuration
* in order to access Gii:
*
* ~~~
* 'rules' => [
* 'gii' => 'gii',
* 'gii/<controller>' => 'gii/<controller>',
* 'gii/<controller>/<action>' => 'gii/<controller>/<action>',
* ...
* ],
* ~~~
*
* You can then access Gii via URL: `http://localhost/path/to/index.php/gii`
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class Module extends \yii\base\Module class Module extends \yii\base\Module implements BootstrapInterface
{ {
/** /**
* @inheritdoc * @inheritdoc
...@@ -90,15 +78,17 @@ class Module extends \yii\base\Module ...@@ -90,15 +78,17 @@ class Module extends \yii\base\Module
*/ */
public $newDirMode = 0777; public $newDirMode = 0777;
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function init() public function bootstrap($app)
{ {
parent::init(); $app->getUrlManager()->addRules([
foreach (array_merge($this->coreGenerators(), $this->generators) as $id => $config) { $this->id => $this->id . '/default/index',
$this->generators[$id] = Yii::createObject($config); $this->id . '/<id:\w+>' => $this->id . '/default/view',
} $this->id . '/<controller:\w+>/<action:\w+>' => $this->id . '/<controller>/<action>',
], false);
} }
/** /**
...@@ -106,6 +96,10 @@ class Module extends \yii\base\Module ...@@ -106,6 +96,10 @@ class Module extends \yii\base\Module
*/ */
public function beforeAction($action) public function beforeAction($action)
{ {
foreach (array_merge($this->coreGenerators(), $this->generators) as $id => $config) {
$this->generators[$id] = Yii::createObject($config);
}
if ($this->checkAccess()) { if ($this->checkAccess()) {
return parent::beforeAction($action); return parent::beforeAction($action);
} else { } else {
......
...@@ -32,11 +32,12 @@ Once the extension is installed, simply modify your application configuration as ...@@ -32,11 +32,12 @@ Once the extension is installed, simply modify your application configuration as
```php ```php
return [ return [
'modules' => [ 'bootstrap' => ['gii'],
'gii' => 'yii\gii\Module', 'modules' => [
... 'gii' => 'yii\gii\Module',
], // ...
... ],
// ...
]; ];
``` ```
...@@ -45,3 +46,9 @@ You can then access Gii through the following URL: ...@@ -45,3 +46,9 @@ You can then access Gii through the following URL:
``` ```
http://localhost/path/to/index.php?r=gii http://localhost/path/to/index.php?r=gii
``` ```
or if you have enabled pretty URLs, you may use the following URL:
```
http://localhost/path/to/index.php/gii
```
...@@ -12,11 +12,13 @@ Yii Framework 2 Change Log ...@@ -12,11 +12,13 @@ Yii Framework 2 Change Log
- Bug #3128: Fixed the bug that `defaultRoles` set in RBAC manager was not working as specified (qiangxue) - Bug #3128: Fixed the bug that `defaultRoles` set in RBAC manager was not working as specified (qiangxue)
- Bug #3153: Fixed the bug that using "between" operator to build a SQL query will cause a PHP notice (gonimar) - Bug #3153: Fixed the bug that using "between" operator to build a SQL query will cause a PHP notice (gonimar)
- Enh #2837: Error page now shows arguments in stack trace method calls (samdark) - Enh #2837: Error page now shows arguments in stack trace method calls (samdark)
- Enh #3088: The debug and gii modules will manage their own URL rules now (hiltonjanfield, qiangxue)
- Enh #3103: debugger panel is now not displayed when printing a page (githubjeka) - Enh #3103: debugger panel is now not displayed when printing a page (githubjeka)
- Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue) - Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue)
- Enh #3132: `yii\rbac\PhpManager` now supports more compact data file format (qiangxue) - Enh #3132: `yii\rbac\PhpManager` now supports more compact data file format (qiangxue)
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue) - Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue) - Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
- Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue) - Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue)
- Chg: Added `$user` as the first parameter of `yii\rbac\Rule::execute()` (qiangxue) - Chg: Added `$user` as the first parameter of `yii\rbac\Rule::execute()` (qiangxue)
......
...@@ -423,8 +423,8 @@ class Formatter extends Component ...@@ -423,8 +423,8 @@ class Formatter extends Component
if ($value === null) { if ($value === null) {
return $this->nullDisplay; return $this->nullDisplay;
} }
$ds = isset($this->decimalSeparator) ? $this->decimalSeparator: '.'; $ds = isset($this->decimalSeparator) ? $this->decimalSeparator : '.';
$ts = isset($this->thousandSeparator) ? $this->thousandSeparator: ','; $ts = isset($this->thousandSeparator) ? $this->thousandSeparator : ',';
return number_format($value, $decimals, $ds, $ts); return number_format($value, $decimals, $ds, $ts);
} }
......
...@@ -552,7 +552,7 @@ class DbManager extends BaseManager ...@@ -552,7 +552,7 @@ class DbManager extends BaseManager
{ {
return (new Query) return (new Query)
->from($this->itemChildTable) ->from($this->itemChildTable)
->where(['parent' => $parent->name, 'child' => $child->$name]) ->where(['parent' => $parent->name, 'child' => $child->name])
->one($this->db) !== false; ->one($this->db) !== false;
} }
......
...@@ -133,14 +133,7 @@ class UrlManager extends Component ...@@ -133,14 +133,7 @@ class UrlManager extends Component
public function init() public function init()
{ {
parent::init(); parent::init();
$this->compileRules();
}
/**
* Parses the URL rules.
*/
protected function compileRules()
{
if (!$this->enablePrettyUrl || empty($this->rules)) { if (!$this->enablePrettyUrl || empty($this->rules)) {
return; return;
} }
...@@ -152,15 +145,53 @@ class UrlManager extends Component ...@@ -152,15 +145,53 @@ class UrlManager extends Component
$hash = md5(json_encode($this->rules)); $hash = md5(json_encode($this->rules));
if (($data = $this->cache->get($cacheKey)) !== false && isset($data[1]) && $data[1] === $hash) { if (($data = $this->cache->get($cacheKey)) !== false && isset($data[1]) && $data[1] === $hash) {
$this->rules = $data[0]; $this->rules = $data[0];
} else {
return; $this->rules = $this->buildRules($this->rules);
$this->cache->set($cacheKey, [$this->rules, $hash]);
} }
} else {
$this->rules = $this->buildRules($this->rules);
}
}
/**
* Adds additional URL rules.
*
* This method will call [[buildRules()]] to parse the given rule declarations and then append or insert
* them to the existing [[rules]].
*
* Note that if [[enablePrettyUrl]] is false, this method will do nothing.
*
* @param array $rules the new rules to be added. Each array element represents a single rule declaration.
* Please refer to [[rules]] for the acceptable rule format.
* @param boolean $append whether to add the new rules by appending them to the end of the existing rules.
*/
public function addRules($rules, $append = true)
{
if (!$this->enablePrettyUrl) {
return;
} }
$rules = $this->buildRules($rules);
if ($append) {
$this->rules = array_merge($this->rules, $rules);
} else {
$this->rules = array_merge($rules, $this->rules);
}
}
$rules = []; /**
* Builds URL rule objects from the given rule declarations.
* @param array $rules the rule declarations. Each array element represents a single rule declaration.
* Please refer to [[rules]] for the acceptable rule formats.
* @return UrlRuleInterface[] the rule objects built from the given rule declarations
* @throws InvalidConfigException if a rule declaration is invalid
*/
protected function buildRules($rules)
{
$compiledRules = [];
$verbs = 'GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS'; $verbs = 'GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS';
foreach ($this->rules as $key => $rule) { foreach ($rules as $key => $rule) {
if (!is_array($rule)) { if (is_string($rule)) {
$rule = ['route' => $rule]; $rule = ['route' => $rule];
if (preg_match("/^((?:($verbs),)*($verbs))\\s+(.*)$/", $key, $matches)) { if (preg_match("/^((?:($verbs),)*($verbs))\\s+(.*)$/", $key, $matches)) {
$rule['verb'] = explode(',', $matches[1]); $rule['verb'] = explode(',', $matches[1]);
...@@ -169,17 +200,15 @@ class UrlManager extends Component ...@@ -169,17 +200,15 @@ class UrlManager extends Component
} }
$rule['pattern'] = $key; $rule['pattern'] = $key;
} }
$rule = Yii::createObject(array_merge($this->ruleConfig, $rule)); if (is_array($rule)) {
$rule = Yii::createObject(array_merge($this->ruleConfig, $rule));
}
if (!$rule instanceof UrlRuleInterface) { if (!$rule instanceof UrlRuleInterface) {
throw new InvalidConfigException('URL rule class must implement UrlRuleInterface.'); throw new InvalidConfigException('URL rule class must implement UrlRuleInterface.');
} }
$rules[] = $rule; $compiledRules[] = $rule;
}
$this->rules = $rules;
if (isset($cacheKey, $hash)) {
$this->cache->set($cacheKey, [$this->rules, $hash]);
} }
return $compiledRules;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment