@@ -13,37 +13,73 @@ class RoutesFilter extends ActionFilter
1313
1414 public function beforeAction ($ action )
1515 {
16- if (!($ this ->type == 'before ' )) {
16+ if (!($ this ->type == 'before ' ))
17+ {
1718 return TRUE ;
1819 }
1920
20- if (is_callable ($ this ->rule )) {
21+ if (is_callable ($ this ->rule ))
22+ {
2123 $ return_data = call_user_func ($ this ->rule );
2224
23- if (!is_bool ($ return_data )) {
25+ if (!is_bool ($ return_data ))
26+ {
2427 return FALSE ;
2528 }
29+
2630 return TRUE ;
2731 }
32+
2833 return FALSE ;
2934 }
3035
3136 public function afterAction ($ action , $ result )
3237 {
33- if (!($ this ->type == 'after ' )) {
38+ if (!($ this ->type == 'after ' ))
39+ {
3440 return $ result ;
3541 }
3642
37- if (is_callable ($ this ->rule )) {
43+ if (is_callable ($ this ->rule ))
44+ {
3845 $ return_data = call_user_func ($ this ->rule );
3946
40- if (!is_bool ($ return_data )) {
47+ if (!is_bool ($ return_data ))
48+ {
4149 return FALSE ;
4250 }
51+
4352 return $ result ;
4453 }
54+
4555 return FALSE ;
4656 }
4757
48- }
4958
59+ /**
60+ * @inheritdoc
61+ * @param \yii\base\Action $action
62+ * @return bool
63+ */
64+ protected function isActive ($ action )
65+ {
66+ if ($ this ->owner instanceof Module)
67+ {
68+ // convert action uniqueId into an ID relative to the module
69+ $ mid = $ this ->owner ->getUniqueId ();
70+ $ id = $ action ->getUniqueId ();
71+ if ($ mid !== '' && strpos ($ id , $ mid ) === 0 )
72+ {
73+ $ id = substr ($ id , strlen ($ mid ) + 1 );
74+ }
75+
76+ $ id = $ action ->controller ->id . '/ ' . $ id ;
77+ }
78+ else
79+ {
80+ $ id = $ action ->controller ->id . '/ ' . $ action ->id ;
81+ }
82+
83+ return !in_array ($ id , $ this ->except , TRUE ) && (empty ($ this ->only ) || in_array ($ id , $ this ->only , TRUE ));
84+ }
85+ }
0 commit comments