File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * author : forecho <caizhenghai@gmail.com>
4+ * createTime : 2020/2/17 9:12 下午
5+ * description:
6+ */
7+
8+ namespace yiier \returnUrl ;
9+
10+ use yii \base \BootstrapInterface ;
11+ use yii \base \Controller ;
12+ use yii \base \Event ;
13+
14+ class EventBootstrap implements BootstrapInterface
15+ {
16+ public $ uniqueIds ;
17+
18+ public function bootstrap ($ app )
19+ {
20+ $ controllerEvents = [
21+ Controller::EVENT_BEFORE_ACTION ,
22+ ];
23+
24+ foreach ($ controllerEvents as $ eventName ) {
25+ Event::on (Controller::class, $ eventName , function ($ event ) {
26+ /** @var Controller $controller */
27+ $ controller = $ event ->sender ;
28+ $ controller ->attachBehavior ('return-url ' , [
29+ 'class ' => ReturnUrl::class,
30+ 'uniqueIds ' => $ this ->uniqueIds
31+ ]);
32+ });
33+ }
34+ }
35+ }
Original file line number Diff line number Diff line change @@ -32,6 +32,21 @@ to the require section of your `composer.json` file.
3232Usage
3333-----
3434
35+ ## Method One (方式一,推荐)
36+
37+ you need to include it in config in bootstrap section:
38+
39+ ``` php
40+ return [
41+ 'bootstrap' => [
42+ 'yiier\returnUrl\EventBootstrap',
43+ ],
44+ ];
45+ ```
46+
47+
48+ ## Method Two (方式二)
49+
3550In your controller add ReturnUrl filter to behaviors:
3651
3752``` php
Original file line number Diff line number Diff line change 55 * createTime : 2016/3/16 10:14
66 * description:
77 */
8- namespace yiier \ReturnUrl ;
8+
9+ namespace yiier \returnUrl ;
910
1011use Yii ;
1112use yii \base \ActionFilter ;
@@ -20,6 +21,7 @@ class ReturnUrl extends ActionFilter
2021 /**
2122 * @param \yii\base\Action $action
2223 * @return bool
24+ * @throws \yii\base\InvalidConfigException
2325 */
2426 public function beforeAction ($ action )
2527 {
You can’t perform that action at this time.
0 commit comments