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.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends Component
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$controller the controller that owns this action
$id ID of the action

공개 메소드들

메소드 설명
__construct ( string $id, Controller $controller, array $config = [] ) Constructor.
getUniqueId ( ) : string Returns the unique ID of this action among the whole application.
runWithParams ( array $params ) : mixed Runs this action with the specified parameters.

보호된 메소드들

메소드 설명
afterRun ( ) This method is called right after run() is executed.
beforeRun ( ) : boolean This method is called right before run() is executed.

메소드 상세

__construct() 공개 메소드

Constructor.
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.
protected afterRun ( )

beforeRun() 보호된 메소드

You may override this method to do preparation work for the action run. If the method returns false, it will cancel the action.
protected beforeRun ( ) : boolean
리턴 boolean whether to run the action.

getUniqueId() 공개 메소드

Returns the unique ID of this action among the whole application.
public getUniqueId ( ) : string
리턴 string the unique ID of this action among the whole application.

runWithParams() 공개 메소드

This method is mainly invoked by the controller.
public runWithParams ( array $params ) : mixed
$params array the parameters to be bound to the action's run() method.
리턴 mixed the result of the action

프로퍼티 상세

$controller 공개적으로 프로퍼티

the controller that owns this action
public $controller

$id 공개적으로 프로퍼티

ID of the action
public $id