mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Development
- [FEATURE] Namespace overwrite now works globally. 'Service¨' will append namespace whereas '\Service' will overwrite it. - [FEATURE] Exceptionhandlers are now rendered in reverse order from newest to oldest. This allows for exceptions to be handled from parent exceptions which were otherwise ignored. - Fixed incorrect return type for InputFile::getError to nullable int. - Added return type to all, match, controller and resource in SimpleRouter class. - Fixed incorrect usage of parse_str in Url::setQueryString method. - Fixed incorrect expected value in array_flip in Url::removeParams method.
This commit is contained in:
@@ -337,6 +337,17 @@ abstract class Route implements IRoute
|
||||
*/
|
||||
public function setNamespace(string $namespace): IRoute
|
||||
{
|
||||
$ns = $this->getNamespace();
|
||||
|
||||
if ($ns !== null) {
|
||||
// Don't overwrite namespaces that starts with \
|
||||
if ($ns[0] !== '\\') {
|
||||
$namespace .= '\\' . $ns;
|
||||
} else {
|
||||
$namespace = $ns;
|
||||
}
|
||||
}
|
||||
|
||||
$this->namespace = $namespace;
|
||||
|
||||
return $this;
|
||||
@@ -407,7 +418,7 @@ abstract class Route implements IRoute
|
||||
*/
|
||||
public function setSettings(array $settings, bool $merge = false): IRoute
|
||||
{
|
||||
if ($this->namespace === null && isset($settings['namespace']) === true) {
|
||||
if (isset($settings['namespace']) === true) {
|
||||
$this->setNamespace($settings['namespace']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user