PHP Class yii\filters\VerbFilter

It allows to define allowed HTTP request methods for each action and will throw an HTTP 405 error when the method is not allowed. To use VerbFilter, declare it in the behaviors() method of your controller class. For example, the following declarations will define a typical set of allowed request methods for REST CRUD actions. php public function behaviors() { return [ 'verbs' => [ 'class' => \yii\filters\VerbFilter::className(), 'actions' => [ 'index' => ['get'], 'view' => ['get'], 'create' => ['get', 'post'], 'update' => ['get', 'put', 'post'], 'delete' => ['post', 'delete'], ], ], ]; }
See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7
Since: 2.0
Author: Carsten Brandt ([email protected])
Inheritance: extends yii\base\Behavior
Datei anzeigen Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$actions this property defines the allowed request methods for each action. For each action that should only support limited set of request methods you add an entry with the action id as array key and an array of allowed methods (e.g. GET, HEAD, PUT) as the value. If an action is not listed all request methods are considered allowed. You can use '*' to stand for all actions. When an action is explicitly specified, it takes precedence over the specification given by '*'. For example, php [ 'create' => ['get', 'post'], 'update' => ['get', 'put', 'post'], 'delete' => ['post', 'delete'], '*' => ['get'], ]

Public Methods

Method Description
beforeAction ( ActionEvent $event ) : boolean
events ( ) : array Declares event handlers for the [[owner]]'s events.

Method Details

beforeAction() public method

public beforeAction ( ActionEvent $event ) : boolean
$event yii\base\ActionEvent
return boolean

events() public method

Declares event handlers for the [[owner]]'s events.
public events ( ) : array
return array events (array keys) and the corresponding event handler methods (array values).

Property Details

$actions public_oe property

this property defines the allowed request methods for each action. For each action that should only support limited set of request methods you add an entry with the action id as array key and an array of allowed methods (e.g. GET, HEAD, PUT) as the value. If an action is not listed all request methods are considered allowed. You can use '*' to stand for all actions. When an action is explicitly specified, it takes precedence over the specification given by '*'. For example, php [ 'create' => ['get', 'post'], 'update' => ['get', 'put', 'post'], 'delete' => ['post', 'delete'], '*' => ['get'], ]
public $actions