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

4.x - Add route context helper #2759

Merged
merged 1 commit into from Jul 19, 2019

Conversation

@shadowhand
Copy link
Contributor

commented Jul 19, 2019

Creates a new RouteContext class that can be used to gain access to the current request route, route parser, and routing results.

Fixes #2758
Fixes #2761

@shadowhand shadowhand force-pushed the shadowhand:feature/route-context branch 2 times, most recently from cd05ad1 to 8b43cfc Jul 19, 2019

@coveralls

This comment has been minimized.

Copy link

commented Jul 19, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 42717a2 on shadowhand:feature/route-context into c4bdfa0 on slimphp:4.x.

@adriansuter

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

Looks good, althoug I have to check in more depth.

Could you please add the slim file header comment to the two new files?

@shadowhand shadowhand force-pushed the shadowhand:feature/route-context branch from 8b43cfc to b133b49 Jul 19, 2019

@shadowhand

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

@adriansuter

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

In RouteContex::fromRequest(), should we check if the three calls to
$serverRequest->getAttribute() did not return null?

Show resolved Hide resolved Slim/App.php Outdated
Show resolved Hide resolved Slim/App.php Outdated

@l0gicgate l0gicgate added this to the 4.0.0 milestone Jul 19, 2019

@l0gicgate l0gicgate added the Slim 4 label Jul 19, 2019

@shadowhand

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

@adriansuter and do what? Throw an exception? PHP will already throw a TypeError if the values are null when trying to construct the RouteContext.

@l0gicgate

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

@shadowhand we need to throw an exception to notify the user that routing hasn't been performed if those attributes are null. Probably throw a RuntimeException

@adriansuter

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

Or an InvalidArgumentException as actually the given argument does not have sufficient information.

But then, a call to this static method has to be wrapped into a try-catch block. Probably it is better to throw a RuntimeException.

@shadowhand shadowhand force-pushed the shadowhand:feature/route-context branch from b133b49 to 47bdac9 Jul 19, 2019

@shadowhand

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

@l0gicgate @adriansuter updated with your requested changes.

@shadowhand shadowhand force-pushed the shadowhand:feature/route-context branch 2 times, most recently from 6871ad1 to 4393d1e Jul 19, 2019

@adriansuter
Copy link
Contributor

left a comment

Some imports can be removed.

Show resolved Hide resolved Slim/App.php Outdated
Show resolved Hide resolved Slim/App.php Outdated

@shadowhand shadowhand force-pushed the shadowhand:feature/route-context branch from 4393d1e to 17ea516 Jul 19, 2019

@shadowhand shadowhand force-pushed the shadowhand:feature/route-context branch from 17ea516 to 42717a2 Jul 19, 2019

@l0gicgate
Copy link
Contributor

left a comment

Looks good to me @adriansuter can you review one last time before I merge please?

@adriansuter

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

Thanks - everything is fine.

@adriansuter

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

We should not forget to update the docs about this new feature.

@l0gicgate

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

@adriansuter absolutely

@l0gicgate l0gicgate merged commit 04be469 into slimphp:4.x Jul 19, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 100.0%
Details

@l0gicgate l0gicgate changed the title Add route context helper 4.x - Add route context helper Jul 19, 2019

@shadowhand shadowhand deleted the shadowhand:feature/route-context branch Jul 19, 2019

@l0gicgate l0gicgate referenced this pull request Aug 1, 2019

Merged

Slim 4 Release #2769

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.