Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: router service adds backslash to controllername if route is configured #2520

Closed
chriseilander opened this issue Jan 29, 2020 · 1 comment · Fixed by #2734
Closed

Bug: router service adds backslash to controllername if route is configured #2520

chriseilander opened this issue Jan 29, 2020 · 1 comment · Fixed by #2734
Assignees
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@chriseilander
Copy link

chriseilander commented Jan 29, 2020

Describe the bug
When a route isn't defined, the controllerName() function in service('router') returns an expected string like 'App\Controllers{controllername}'. But when a route is defined in the routes.php it also returns an extra \ like '\App\Controllers{controllername}'.

CodeIgniter 4 version
CodeIgniter 4 RC 3 zip version
CodeIgniter 4 Dev starter composer
CodeIgniter 4 App starter composer

Affected module(s)
Probably the router service

Expected behavior, and steps to reproduce if appropriate
Let the namespace define the route, and return the controller name using
$router = service("router"); echo $router->controllerName();
It should return the namespace of the controller with the name.

Now define the route in routes.php, and the same code will return an \ with the namespace of the controller with the controllername.

I expected them to be the same.

@chriseilander chriseilander added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 29, 2020
@chriseilander chriseilander changed the title Bug: router service adds backspace to controllername if route is configured Bug: router service adds backslash to controllername if route is configured Jan 29, 2020
@MGatner MGatner self-assigned this Feb 16, 2020
samsonasik added a commit to samsonasik/CodeIgniter4 that referenced this issue Mar 21, 2020
@samsonasik
Copy link
Member

@chriseilander @MGatner I think the correct one is the one with \ prefix as it fqcn like in the doc comment at https://github.com/codeigniter4/CodeIgniter4/pull/2734/files#diff-d2374d65fd714c18dbee9f5adaa8dd6cL552.

I created PR #2734 for it.

samsonasik added a commit to samsonasik/CodeIgniter4 that referenced this issue Mar 23, 2020
MGatner added a commit that referenced this issue Mar 23, 2020
Fixes #2520 : ensure service(router)->controllername() returns fqcn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants