From 18401399fedbadc6f50f7eb815d6738901ad5a2e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 4 Sep 2019 00:35:53 +0300 Subject: [PATCH] Inline constant since it is not part of the public interface In Yii 3 instead I'd make constant private but we have no PHP 7 in 2.0 --- framework/base/Controller.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 4caec4f8ee..9921cfec6e 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -37,10 +37,6 @@ class Controller extends Component implements ViewContextInterface * @event ActionEvent an event raised right after executing a controller action. */ const EVENT_AFTER_ACTION = 'afterAction'; - /** - * Action ID to method name generation regexp - */ - const ACTION_ID_METHOD_REGEXP = '/^(?:[a-z0-9_]+-)*[a-z0-9_]+$/'; /** * @var string the ID of this controller. @@ -229,7 +225,9 @@ class Controller extends Component implements ViewContextInterface $actionMap = $this->actions(); if (isset($actionMap[$id])) { return Yii::createObject($actionMap[$id], [$id, $this]); - } elseif (preg_match(self::ACTION_ID_METHOD_REGEXP, $id)) { + } + + if (preg_match('/^(?:[a-z0-9_]+-)*[a-z0-9_]+$/', $id)) { $methodName = 'action' . str_replace(' ', '', ucwords(str_replace('-', ' ', $id))); if (method_exists($this, $methodName)) { $method = new \ReflectionMethod($this, $methodName);