Class yii\base\ActionFilter
ActionFilter 是动作过滤器的基类。
An action filter will participate in the action execution workflow by responding to
the beforeAction
and afterAction
events triggered by modules and controllers.
Check implementation of yii\filters\AccessControl, yii\filters\PageCache and yii\filters\HttpCache as examples on how to use it.
For more details and usage information on ActionFilter, see the guide article on filters.
公共属性
属性 | 类型 | 描述 | 被定义在 |
---|---|---|---|
$except | array | List of action IDs that this filter should not apply to. | yii\base\ActionFilter |
$only | array | List of action IDs that this filter should apply to. | yii\base\ActionFilter |
$owner | yii\base\Component|null | The owner of this behavior | yii\base\Behavior |
公共方法
方法 | 描述 | 被定义在 |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\BaseObject |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of an object property. | yii\base\BaseObject |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() | Sets value of an object property. | yii\base\BaseObject |
__unset() | Sets an object property to null. | yii\base\BaseObject |
afterAction() | 执行动作后立即调用此方法。 您可以覆盖此方法以对操作执行一些后处理。 | yii\base\ActionFilter |
afterFilter() | yii\base\ActionFilter | |
attach() | Attaches the behavior object to the component. | yii\base\ActionFilter |
beforeAction() | This method is invoked right before an action is to be executed (after all possible filters.) You may override this method to do last-minute preparation for the action. | yii\base\ActionFilter |
beforeFilter() | yii\base\ActionFilter | |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
detach() | Detaches the behavior object from the component. | yii\base\ActionFilter |
events() | Declares event handlers for the $owner's events. | yii\base\Behavior |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() | Initializes the object. | yii\base\BaseObject |
受保护的方法
方法 | 描述 | 被定义在 |
---|---|---|
getActionId() | 通过将 yii\base\Action::$uniqueId 转换为相对于模块的 ID 来返回动作 ID。 | yii\base\ActionFilter |
isActive() | 返回一个值,该值指示过滤器对于给定操作是否处于活动状态。 | yii\base\ActionFilter |
属性详情
List of action IDs that this filter should not apply to.
参见 $only.
List of action IDs that this filter should apply to. If this property is not set, then the filter applies to all actions, unless they are listed in $except. If an action ID appears in both $only and $except, this filter will NOT apply to it.
Note that if the filter is attached to a module, the action IDs should also include child module IDs (if any) and controller IDs.
Since version 2.0.9 action IDs can be specified as wildcards, e.g. site/*
.
参见 $except.
方法详情
执行动作后立即调用此方法。 您可以覆盖此方法以对操作执行一些后处理。
public mixed afterAction($action, $result) | ||
$action | yii\base\Action | 刚执行的动作。 |
$result | mixed | 动作执行结果 |
return | mixed | 处理后的动作结果。 |
---|
public void afterFilter($event) | ||
$event | yii\base\ActionEvent |
Attaches the behavior object to the component.
The default implementation will set the $owner property and attach event handlers as declared in events(). Make sure you call the parent implementation if you override this method.
public void attach($owner) | ||
$owner | yii\base\Component | The component that this behavior is to be attached to. |
This method is invoked right before an action is to be executed (after all possible filters.) You may override this method to do last-minute preparation for the action.
public boolean beforeAction($action) | ||
$action | yii\base\Action | 要执行的动作。 |
return | boolean | 该动作是否应继续执行。 |
---|
public void beforeFilter($event) | ||
$event | yii\base\ActionEvent |
Detaches the behavior object from the component.
The default implementation will unset the $owner property and detach event handlers declared in events(). Make sure you call the parent implementation if you override this method.
public void detach() |
通过将 yii\base\Action::$uniqueId 转换为相对于模块的 ID 来返回动作 ID。
protected string getActionId($action) | ||
$action | yii\base\Action |
返回一个值,该值指示过滤器对于给定操作是否处于活动状态。
protected boolean isActive($action) | ||
$action | yii\base\Action | 被过滤的动作 |
return | boolean | 过滤器对于给定的动作是否处于活动状态。 |
---|