mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-17 06:48:59 +08:00
Replaced id2camel with direct implementation
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
namespace yii\base;
|
namespace yii\base;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\StringHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller is the base class for classes containing controller logic.
|
* Controller is the base class for classes containing controller logic.
|
||||||
@@ -226,7 +225,7 @@ class Controller extends Component
|
|||||||
if (isset($actionMap[$id])) {
|
if (isset($actionMap[$id])) {
|
||||||
return Yii::createObject($actionMap[$id], $id, $this);
|
return Yii::createObject($actionMap[$id], $id, $this);
|
||||||
} elseif (preg_match('/^[a-z0-9\\-_]+$/', $id)) {
|
} elseif (preg_match('/^[a-z0-9\\-_]+$/', $id)) {
|
||||||
$methodName = 'action' . StringHelper::id2camel($id);
|
$methodName = 'action' . str_replace(' ', '', ucwords(implode(' ', explode('-', $id))));
|
||||||
if (method_exists($this, $methodName)) {
|
if (method_exists($this, $methodName)) {
|
||||||
$method = new \ReflectionMethod($this, $methodName);
|
$method = new \ReflectionMethod($this, $methodName);
|
||||||
if ($method->getName() === $methodName) {
|
if ($method->getName() === $methodName) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
namespace yii\base;
|
namespace yii\base;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\StringHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module is the base class for module and application classes.
|
* Module is the base class for module and application classes.
|
||||||
@@ -609,7 +608,7 @@ abstract class Module extends Component
|
|||||||
if (isset($this->controllerMap[$id])) {
|
if (isset($this->controllerMap[$id])) {
|
||||||
$controller = Yii::createObject($this->controllerMap[$id], $id, $this);
|
$controller = Yii::createObject($this->controllerMap[$id], $id, $this);
|
||||||
} elseif (preg_match('/^[a-z0-9\\-_]+$/', $id)) {
|
} elseif (preg_match('/^[a-z0-9\\-_]+$/', $id)) {
|
||||||
$className = StringHelper::id2camel($id) . 'Controller';
|
$className = str_replace(' ', '', ucwords(implode(' ', explode('-', $id)))) . 'Controller';
|
||||||
$classFile = $this->controllerPath . DIRECTORY_SEPARATOR . $className . '.php';
|
$classFile = $this->controllerPath . DIRECTORY_SEPARATOR . $className . '.php';
|
||||||
if (!is_file($classFile)) {
|
if (!is_file($classFile)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user