Class yii\filters\AjaxFilter
Inheritance | yii\filters\AjaxFilter » yii\base\ActionFilter » yii\base\Behavior » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0.13 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/filters/AjaxFilter.php |
AjaxFilter allow to limit access only for ajax requests.
public function behaviors()
{
return [
[
'class' => 'yii\filters\AjaxFilter',
'only' => ['index']
],
];
}
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$errorMessage | string | The message to be displayed when request isn't ajax | yii\filters\AjaxFilter |
$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 |
$request | yii\web\Request | The current request. | yii\filters\AjaxFilter |
Public Methods
Method | Description | Defined By |
---|---|---|
__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() | This method is invoked right after an action is executed. | yii\base\ActionFilter |
afterFilter() | yii\base\ActionFilter | |
attach() | Attaches the behavior object to the component. | yii\base\Behavior |
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\filters\AjaxFilter |
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\Behavior |
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\filters\AjaxFilter |
Protected Methods
Method | Description | Defined By |
---|---|---|
getActionId() | Returns an action ID by converting yii\base\Action::$uniqueId into an ID relative to the module. | yii\base\ActionFilter |
isActive() | Returns a value indicating whether the filter is active for the given action. | yii\base\ActionFilter |
Property Details
The message to be displayed when request isn't ajax
The current request. If not set, the request
application component will be used.
Method Details
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 | The action to be executed. |
return | boolean | Whether the action should continue to be executed. |
---|
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
public void init ( ) |