Skip to content

Commit 58120fc

Browse files
committed
fix: fix bug
1 parent 282b18a commit 58120fc

File tree

3 files changed

+20
-46
lines changed

3 files changed

+20
-46
lines changed

EventBootstrap.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ Usage
3434

3535
## Method One (方式一,推荐)
3636

37-
you need to include it in config in bootstrap section:
37+
you need to include it in config:
3838

3939
```php
4040
return [
41-
'bootstrap' => [
42-
'yiier\returnUrl\EventBootstrap',
43-
],
41+
'on beforeAction' => function ($event) {
42+
Yii::createObject([
43+
'class' => \yiier\returnUrl\ReturnUrl::class,
44+
'uniqueIds' => ['site/qrcode', 'site/login', 'site/signup']
45+
])->beforeAction();
46+
},
47+
'components' => [
48+
]
4449
];
4550
```
4651

ReturnUrl.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,28 @@
99
namespace yiier\returnUrl;
1010

1111
use Yii;
12-
use yii\base\ActionFilter;
12+
use yii\base\Behavior;
13+
use yii\web\Controller;
1314

14-
class ReturnUrl extends ActionFilter
15+
class ReturnUrl extends Behavior
1516
{
1617
/**
1718
* @var array
1819
*/
1920
public $uniqueIds = ['site/login'];
2021

22+
public function events()
23+
{
24+
return [
25+
Controller::EVENT_BEFORE_ACTION => 'beforeAction',
26+
];
27+
}
28+
2129
/**
22-
* @param \yii\base\Action $action
2330
* @return bool
2431
* @throws \yii\base\InvalidConfigException
2532
*/
26-
public function beforeAction($action)
33+
public function beforeAction()
2734
{
2835
if (Yii::$app->user->isGuest) {
2936
if (!(Yii::$app->request->getIsAjax() || $this->isValidate())) {

0 commit comments

Comments
 (0)