1 | <?php |
||
24 | class ActionFilter extends Behavior |
||
25 | { |
||
26 | /** |
||
27 | * @var array list of action IDs that this filter should apply to. If this property is not set, |
||
28 | * then the filter applies to all actions, unless they are listed in [[except]]. |
||
29 | * If an action ID appears in both [[only]] and [[except]], this filter will NOT apply to it. |
||
30 | * |
||
31 | * Note that if the filter is attached to a module, the action IDs should also include child module IDs (if any) |
||
32 | * and controller IDs. |
||
33 | * |
||
34 | * Since version 2.0.9 action IDs can be specified as wildcards, e.g. `site/*`. |
||
35 | * |
||
36 | * @see except |
||
37 | */ |
||
38 | public $only; |
||
39 | /** |
||
40 | * @var array list of action IDs that this filter should not apply to. |
||
41 | * @see only |
||
42 | */ |
||
43 | public $except = []; |
||
44 | |||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 61 | public function attach($owner) |
|
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function detach() |
||
66 | |||
67 | /** |
||
68 | * @param ActionEvent $event |
||
69 | */ |
||
70 | 61 | public function beforeFilter($event) |
|
85 | |||
86 | /** |
||
87 | * @param ActionEvent $event |
||
88 | */ |
||
89 | 59 | public function afterFilter($event) |
|
94 | |||
95 | /** |
||
96 | * This method is invoked right before an action is to be executed (after all possible filters.) |
||
97 | * You may override this method to do last-minute preparation for the action. |
||
98 | * @param Action $action the action to be executed. |
||
99 | * @return bool whether the action should continue to be executed. |
||
100 | */ |
||
101 | public function beforeAction($action) |
||
105 | |||
106 | /** |
||
107 | * This method is invoked right after an action is executed. |
||
108 | * You may override this method to do some postprocessing for the action. |
||
109 | * @param Action $action the action just executed. |
||
110 | * @param mixed $result the action execution result |
||
111 | * @return mixed the processed action result. |
||
112 | */ |
||
113 | 58 | public function afterAction($action, $result) |
|
117 | |||
118 | /** |
||
119 | * Returns an action ID by converting [[Action::$uniqueId]] into an ID relative to the module. |
||
120 | * @param Action $action |
||
121 | * @return string |
||
122 | * @since 2.0.7 |
||
123 | */ |
||
124 | 75 | protected function getActionId($action) |
|
138 | |||
139 | /** |
||
140 | * Returns a value indicating whether the filter is active for the given action. |
||
141 | * @param Action $action the action being filtered |
||
142 | * @return bool whether the filter is active for the given action. |
||
143 | */ |
||
144 | 73 | protected function isActive($action) |
|
170 | } |
||
171 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.