PHP Класс 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'], ], ], ]; }
См. также: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7
С версии: 2.0
Автор: Carsten Brandt ([email protected])
Наследование: extends yii\base\Behavior
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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'], ]

Открытые методы

Метод Описание
beforeAction ( ActionEvent $event ) : boolean
events ( ) : array Declares event handlers for the [[owner]]'s events.

Описание методов

beforeAction() публичный Метод

public beforeAction ( ActionEvent $event ) : boolean
$event yii\base\ActionEvent
Результат boolean

events() публичный Метод

Declares event handlers for the [[owner]]'s events.
public events ( ) : array
Результат array events (array keys) and the corresponding event handler methods (array values).

Описание свойств

$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 $actions