Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action after run result #19870

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
83fda4b
Merge pull request #1 from yiisoft/master
rhertogh Jul 30, 2015
5231894
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jan 24, 2020
e388dfc
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jul 16, 2020
6b56e2c
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Aug 20, 2020
1676da7
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Oct 31, 2020
accf01e
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh May 23, 2021
8856e22
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Jun 2, 2021
22f4a41
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Jun 23, 2021
6548c45
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Aug 15, 2021
315bda2
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Sep 13, 2021
3db5c78
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Sep 15, 2021
c164bea
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jan 17, 2022
1b5c680
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh May 16, 2022
91a8582
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jun 13, 2022
c1b3877
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Oct 27, 2022
43b4425
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Apr 10, 2023
bedfa1f
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh May 17, 2023
412399b
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh May 28, 2023
acad979
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jun 26, 2023
74a9bde
Allow post-processing of action result
rhertogh Jun 26, 2023
5c78f02
Added $args parameter to `\yii\base\Action::beforeRun()` and updated …
rhertogh Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions framework/base/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -104,18 +104,22 @@ 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;
}

/**
* 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;
}
}