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: set404Override now working in group rotes #4400

Closed
Gh-Moradi opened this issue Mar 9, 2021 · 2 comments
Closed

Bug: set404Override now working in group rotes #4400

Gh-Moradi opened this issue Mar 9, 2021 · 2 comments

Comments

@Gh-Moradi
Copy link

Gh-Moradi commented Mar 9, 2021

I set the set404Override in group rotes, But it does not work and gives an error.

$routes->group('panel', ['filter' => 'role:Writer'], function($routes) {
	$routes->setDefaultNamespace('App\Controllers\Panel');
	$routes->set404Override('Show404::index');
	$routes->get('home', 'Home::index');
	$routes->get('posts', 'Post::index');
	// And more...
});

But when I set it like this it works right:

$routes->set404Override('App\Controllers\Panel\Show404::index');

Is this a bug? or am i wrong?

I using this platform:
CodeIgniter 4 version

  • OS: Windows 10
  • Web server Apache 2.4.41
  • PHP version 7.3.11
@Gh-Moradi Gh-Moradi added the bug Verified issues on the current code behavior or pull requests that will fix them label Mar 9, 2021
@iRedds
Copy link
Collaborator

iRedds commented Mar 9, 2021

https://codeigniter.com/user_guide/incoming/routing.html#override
In the current version, the method expects the full path to the 404 error handling class.
Also, only one 404 error handler can be defined.

This is not a bug, but normal behavior.

Also, in your case, it would be more correct to specify the namespace through an array

$routes->group('panel', ['filter' => 'role:Writer', 'namespace' => 'App\Controllers\Panel'], function($routes) {
//...
});

@paulbalandan paulbalandan removed the bug Verified issues on the current code behavior or pull requests that will fix them label Mar 11, 2021
@paulbalandan
Copy link
Member

Thanks @iRedds for the explanation. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants