diff --git a/framework/base/Action.php b/framework/base/Action.php index 45d95c59cbf..0f4e6dc78b9 100644 --- a/framework/base/Action.php +++ b/framework/base/Action.php @@ -89,9 +89,9 @@ public function runWithParams($params) if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } - if ($this->beforeRun()) { + if ($this->beforeRun($args)) { $result = call_user_func_array([$this, 'run'], $args); - $this->afterRun(); + $result = $this->afterRun($result); return $result; } @@ -104,9 +104,10 @@ public function runWithParams($params) * You may override this method to do preparation work for the action run. * If the method returns false, it will cancel the action. * + * @param array $args * @return bool whether to run the action. */ - protected function beforeRun() + protected function beforeRun($args) { return true; } @@ -114,8 +115,11 @@ protected function beforeRun() /** * This method is called right after `run()` is executed. * You may override this method to do post-processing work for the action run. + * + * @param mixed $result */ - protected function afterRun() + protected function afterRun($result) { + return $result; } }