yii2 icon indicating copy to clipboard operation
yii2 copied to clipboard

Action after run result

Open rhertogh opened this issue 1 year ago • 7 comments

Q A
Is bugfix? ✔️
New feature? ✔️
Breaks BC? ✔️
Fixed issues #13484

The \yii\base\Action::afterRun() documentation states:

"You may override this method to do post-processing work for the action run"

Currently post-processing is not possible since the $result is not passed to the afterRun() function in the \yii\base\Action::runWithParams() function.

This was discussed earlier, but since Yii 2.1 is cancelled I would like to re-submit this feature.

ToDo:

  • [x] Implementation
  • [ ] Documentation/Changelog/Upgrade steps
  • [ ] Unit tests

rhertogh avatar Jun 26 '23 18:06 rhertogh

PR Summary

  • Updated afterRun() method in framework/base/Action.php
    • Modified the method call to pass the $result parameter
    • Added a new parameter $result to the method
    • Included a proper return statement for the method

what-the-diff[bot] avatar Jun 26 '23 18:06 what-the-diff[bot]

@samdark @bizley What do you think?

rhertogh avatar Jun 26 '23 18:06 rhertogh

This is a big BC break, not sure if we want to change it like that.

bizley avatar Jun 27 '23 08:06 bizley

@rhertogh do you have a use-case for it or is it based mainly on the contradiction of current code with phpdoc?

samdark avatar Jun 29 '23 14:06 samdark

@samdark I've an actual use case for it where I need to run some code in the beforeRun (based on the arguments) and in the afterRun (based on the result). I thought these functions would solve my needs but then I ran into the issue that the the functions don't behave as expected.

rhertogh avatar Jun 29 '23 18:06 rhertogh

@bizley Something for Yii 2.2?

rhertogh avatar Jun 29 '23 18:06 rhertogh

@rhertogh maybe. I've posted there in a discussion.

samdark avatar Jun 30 '23 03:06 samdark