PHP Class yii2tech\admin\actions\Action

Since: 1.0
Author: Paul Klimov ([email protected])
Inheritance: extends yii\base\Action
Mostra file Open project: yii2tech/admin Class Usage Examples

Public Properties

Property Type Description
$findModel a PHP callable that will be called to return the model corresponding to the specified primary key value. If not set, Action::findModel will be used instead. The signature of the callable should be: php function ($id, $action) { $id is the primary key value. If composite primary key, the key values will be separated by comma. $action is the action object currently running } The callable should return the model found, or throw an exception if not found.
$returnAction ID of the controller action, which user should be redirected to on success. This property overrides the value set by Action::setReturnAction method.
$returnUrl URL, which user should be redirected to on success. This could be a plain string URL, URL array configuration or callable, which returns actual URL. The signature for the callable is following: string|array function (Model $model) } Note: actual list of the callable arguments may vary depending on particular action class. Note: this option takes precedence over [[returnAction]] related logic.

Public Methods

Method Description
actionExists ( string $id ) : boolean Checks whether action with specified ID exists in owner controller.
createReturnUrl ( string $defaultActionId = 'index', yii\db\ActiveRecordInterface | Model | null $model = null ) : array | string
findModel ( string $id ) : yii\db\ActiveRecordInterface | Model Returns the data model based on the primary key given.
getReturnAction ( string $defaultActionId = 'index' ) : string Returns the ID of action, which should be used for return redirect.
setFlash ( string | array | null $message, array $params = [] ) Sets a flash message.
setReturnAction ( string | null $actionId = null ) Sets the return action ID.

Method Details

actionExists() public method

Checks whether action with specified ID exists in owner controller.
public actionExists ( string $id ) : boolean
$id string action ID.
return boolean whether action exists or not.

createReturnUrl() public method

public createReturnUrl ( string $defaultActionId = 'index', yii\db\ActiveRecordInterface | Model | null $model = null ) : array | string
$defaultActionId string default action ID.
$model yii\db\ActiveRecordInterface | yii\base\Model | null model being processed by action.
return array | string URL

findModel() public method

If the data model is not found, a 404 HTTP exception will be raised.
public findModel ( string $id ) : yii\db\ActiveRecordInterface | Model
$id string the ID of the model to be loaded. If the model has a composite primary key, the ID must be a string of the primary key values separated by commas. The order of the primary key values should follow that returned by the `primaryKey()` method of the model.
return yii\db\ActiveRecordInterface | yii\base\Model the model found

getReturnAction() public method

If action belongs to another controller or does not exist in current controller - 'index' is returned.
public getReturnAction ( string $defaultActionId = 'index' ) : string
$defaultActionId string default action ID.
return string action ID.

setFlash() public method

Sets a flash message.
public setFlash ( string | array | null $message, array $params = [] )
$message string | array | null flash message(s) to be set. If plain string is passed, it will be used as a message with the key 'success'. You may specify multiple messages as an array, if element name is not integer, it will be used as a key, otherwise 'success' will be used as key. If empty value passed, no flash will be set. Particular message value can be a PHP callback, which should return actual message. Such callback, should have following signature: ```php function (array $params) { // return string } ```
$params array extra params for the message parsing in format: key => value.

setReturnAction() public method

Sets the return action ID.
public setReturnAction ( string | null $actionId = null )
$actionId string | null action ID, if not set current action will be used.

Property Details

$findModel public_oe property

a PHP callable that will be called to return the model corresponding to the specified primary key value. If not set, Action::findModel will be used instead. The signature of the callable should be: php function ($id, $action) { $id is the primary key value. If composite primary key, the key values will be separated by comma. $action is the action object currently running } The callable should return the model found, or throw an exception if not found.
public $findModel

$returnAction public_oe property

ID of the controller action, which user should be redirected to on success. This property overrides the value set by Action::setReturnAction method.
See also: getReturnAction()
See also: returnUrl
public $returnAction

$returnUrl public_oe property

URL, which user should be redirected to on success. This could be a plain string URL, URL array configuration or callable, which returns actual URL. The signature for the callable is following: string|array function (Model $model) } Note: actual list of the callable arguments may vary depending on particular action class. Note: this option takes precedence over [[returnAction]] related logic.
See also: returnAction
public $returnUrl