diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 4993b893ef..a35b9e1ad2 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -241,12 +241,13 @@ class Controller extends Component implements ViewContextInterface * ```php * public function beforeAction($action) * { - * if (parent::beforeAction($action)) { - * // your custom code here - * return true; // or false if needed - * } else { + * if (!parent::beforeAction($action)) { * return false; * } + * + * // your custom code here + * + * return true; // or false to not run the action * } * ``` * diff --git a/framework/base/Module.php b/framework/base/Module.php index 4fa92972ed..de0cfd063b 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -584,12 +584,13 @@ class Module extends ServiceLocator * ```php * public function beforeAction($action) * { - * if (parent::beforeAction($action)) { - * // your custom code here - * return true; // or false if needed - * } else { + * if (!parent::beforeAction($action)) { * return false; * } + * + * // your custom code here + * + * return true; // or false to not run the action * } * ``` *