Skip to content

Bug: RouteCollection::resource() doesn't work with grouped rules #2829

Description

@rmilecki

Describe the bug
When using routes group and ::resource() then methods receive method name as argument instead of segment. Example:

$routes->group('api', function($routes) {
	$routes->resource('news', ['controller' => 'Api\News' ]);
});

opening /api/news/show/123 results in CI4 calling ->show('show'); ('show' should be '123').

CodeIgniter 4 version
4.0.2

Affected module(s)
RouteCollection

Expected behavior, and steps to reproduce if appropriate
Things work as expected when using:

$routes->group('api', function($routes) {
	$routes->get('news/(:segment)',      'Api\News::show/$1');
});

and according to the documentation initial code using RouteCollection::resource() should be equivalent for that.

Context

  • OS: Linux
  • PHP version 7.4.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions