1 | <?php |
||
39 | class Action extends Component |
||
40 | { |
||
41 | /** |
||
42 | * @var string ID of the action |
||
43 | */ |
||
44 | public $id; |
||
45 | /** |
||
46 | * @var Controller|\yii\web\Controller the controller that owns this action |
||
47 | */ |
||
48 | public $controller; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * Constructor. |
||
53 | * |
||
54 | * @param string $id the ID of this action |
||
55 | * @param Controller $controller the controller that owns this action |
||
56 | * @param array $config name-value pairs that will be used to initialize the object properties |
||
57 | */ |
||
58 | 143 | public function __construct($id, $controller, $config = []) |
|
64 | |||
65 | /** |
||
66 | * Returns the unique ID of this action among the whole application. |
||
67 | * |
||
68 | * @return string the unique ID of this action among the whole application. |
||
69 | */ |
||
70 | 95 | public function getUniqueId() |
|
74 | |||
75 | /** |
||
76 | * Runs this action with the specified parameters. |
||
77 | * This method is mainly invoked by the controller. |
||
78 | * |
||
79 | * @param array $params the parameters to be bound to the action's run() method. |
||
80 | * @return mixed the result of the action |
||
81 | * @throws InvalidConfigException if the action class does not have a run() method |
||
82 | */ |
||
83 | 6 | public function runWithParams($params) |
|
102 | |||
103 | /** |
||
104 | * This method is called right before `run()` is executed. |
||
105 | * You may override this method to do preparation work for the action run. |
||
106 | * If the method returns false, it will cancel the action. |
||
107 | * |
||
108 | * @return bool whether to run the action. |
||
109 | */ |
||
110 | 6 | protected function beforeRun() |
|
114 | |||
115 | /** |
||
116 | * This method is called right after `run()` is executed. |
||
117 | * You may override this method to do post-processing work for the action run. |
||
118 | */ |
||
119 | 6 | protected function afterRun() |
|
122 | } |
||
123 |