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

Redirecting Routes. Placeholders. #5916

Merged
merged 1 commit into from
Apr 23, 2022
Merged

Conversation

iRedds
Copy link
Collaborator

@iRedds iRedds commented Apr 21, 2022

Description
PR adds the ability to use placeholders for route redirects.

$routes->get('post/(:num)/comment/(:num)', 'PostsComments::index', ['as' => 'post.comment']);

// Redirect to a URI
$routes->addRedirect('article/(:num)/(:num)', 'post/$1/comment/$2');
// Redirect to a named route
$routes->addRedirect('article/(:num)/(:num)', 'post.comment');

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

Signed-off-by: Andrey Pyzhikov <5071@mail.ru>
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice new feature! I don't follow all the route replacements but the tests look good and what is expected so I'm going to trust that it is working as intended 😊

@kenjis kenjis added the enhancement PRs that improve existing functionalities label Apr 22, 2022
@kenjis kenjis merged commit 116f663 into codeigniter4:develop Apr 23, 2022
@iRedds iRedds deleted the redirect-route branch April 23, 2022 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants