-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
beforeRun() and afterRun() do not get executed in base\Action #2549
Comments
@qiangxue why did you add them, what's the usecase for them? When implementing an action you have full control over the complete flow so they are not needed imo. |
Imo I don't see any point in |
The use case is you have a base action class and you want to put some common logic that should get executed before/after action run. I added these methods when implementing web api support which needs to check if the current request method is allowed by the action. @ivokund the issue is valid. Need to change |
Fixed. Thanks. |
I think there's a typo in your fix public function runWithParams($params)
{
if (!method_exists($this, 'run')) {
throw new InvalidConfigException(get_class($this) . ' must define a "run()" method.');
}
$args = $this->controller->bindActionParams($this, $params);
Yii::trace('Running action: ' . get_class($this) . '::run()', __METHOD__);
if (Yii::$app->requestedParams === null) {
Yii::$app->requestedParams = $args;
}
if ($this->beforeRun()) {
call_user_func_array([$this, 'run'], $args);
$this->afterRun();
}
} The result of |
Hi,
I see that
beforeRun
andafterRun
were added inyii\base\Action
in @a5968a6a, but I don't see that the methods get actually executed. I assume that the behaviour is supposed to be similar to that in controllers?Excerpt from
base\Action
The text was updated successfully, but these errors were encountered: