Open Jeckerson opened 1 year ago
Please remove all suffixes and namespaces in Router and Dispatcher. This is bad code.
Please change the code to full use of class and method names.
I don't want to have to specify a namespace all the time:
class Dispatcher extends \Phalcon\Mvc\Dispatcher
{
protected $handlerSuffix = '';
protected $actionSuffix = '';
protected $defaultAction = '__invoke';
/**
* Fix Controller::__invoke()
*/
public function getActiveMethod(): string
{
return $this->getActionName() . $this->getActionSuffix();
}
/**
* Fix controller namespace
*/
public function forward(array $forward): void
{
if (isset($forward['controller']) && !isset($forward['namespace'])) {
$parts = explode('\\', $forward['controller']);
if (count($parts) > 1) {
$forward['controller'] = array_pop($parts);
$forward['namespace'] = implode('\\', $parts);
}
}
parent::forward($forward);
}
}
Describe the bug
Controller
suffix is repeated when full classname is specified.To Reproduce
Expected behavior No error when specified full namespace class.
Details