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

route alias does not when used with name() function #1695

Closed
christoph-kluge opened this issue Dec 25, 2019 · 1 comment · Fixed by #1696
Closed

route alias does not when used with name() function #1695

christoph-kluge opened this issue Dec 25, 2019 · 1 comment · Fixed by #1696

Comments

@christoph-kluge
Copy link

christoph-kluge commented Dec 25, 2019

Q A
Bug? no
New Feature? no
Framework Laravel
Framework version 5.8.x
Package version 2.4.0
PHP version 7.3.x

Actual Behaviour

Given the following route definition:

/** @var Router $api */
$api = app(Router::class);
$api->version('v1', function (Router $api) {
    $api->get('entity/{uuid}', MyHandler::class)->name('myalias');
});

When using route('myalias') it will throw an exception Route [myalias] not defined..

Expected Behaviour

Obviously it should not throw an exception

Steps to Reproduce

See actual behavior.

Possible Solutions

After a quick check I've realised that RouteCollection->add() does the name list lookup. The problem is that ->name() is added afterwards to the route, so the route collection is not build up correctly. Refreshing the RouteCollection seems to fix the behavior.

Additional note

It will still fail when we have an exception before the Adapter->dispatch() is hit and we'll use route() during exception handling. Didn't found a better solution for now but it gives us an additional feature for now w/o breaking existing functionality.

@specialtactics
Copy link
Member

Thanks for your work @christoph-kluge !

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

Successfully merging a pull request may close this issue.

2 participants