PHP Класс yii\base\Action
Action provides a way to reuse action method code. An action method in an Action
class can be used in multiple controllers or in different projects.
Derived classes must implement a method named
run(). This method
will be invoked by the controller when the action is requested.
The
run() method can have parameters which will be filled up
with user input values automatically according to their names.
For example, if the
run() method is declared as follows:
php
public function run($id, $type = 'book') { ... }
And the parameters provided for the action are:
['id' => 1].
Then the
run() method will be invoked as
run(1) automatically.
For more details and usage information on Action, see the
guide article on actions.
Показать файл
Открыть проект
Примеры использования класса
Открытые свойства
Свойство |
Тип |
Описание |
|
$controller |
|
the controller that owns this action |
|
$id |
|
ID of the action |
|
Открытые методы
Защищенные методы
Метод |
Описание |
|
afterRun ( ) |
This method is called right after run() is executed. |
|
beforeRun ( ) : boolean |
This method is called right before run() is executed. |
|
Описание методов
__construct()
публичный Метод
public __construct ( string $id, Controller $controller, array $config = [] ) |
$id |
string |
the ID of this action |
$controller |
Controller |
the controller that owns this action |
$config |
array |
name-value pairs that will be used to initialize the object properties |
afterRun()
защищенный Метод
You may override this method to do post-processing work for the action run.
beforeRun()
защищенный Метод
You may override this method to do preparation work for the action run.
If the method returns false, it will cancel the action.
getUniqueId()
публичный Метод
Returns the unique ID of this action among the whole application.
runWithParams()
публичный Метод
This method is mainly invoked by the controller.
Описание свойств
$controller публичное свойство
the controller that owns this action