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 an advanced callable resolver #2787

Merged
merged 23 commits into from Aug 11, 2019

Conversation

@adriansuter
Copy link
Contributor

commented Aug 9, 2019

This PR addresses #2780.

It defines a new AdvancedCallableResolver and a corresponding interface which extends the existing CallableResolverInterface. The advanced callable resolver would be created by default in the App constructor (if none had been passed).

The MiddlewareDispatcher would get the callable resolver as third optional param (non-BC). If it has one, and if the resolver is advanced, then the dispatcher would call the resolveMiddleware method. If the resolver is not advanced or if there is not even a resolver available, the dispatcher would execute its own hard coded resolving.

The \Slim\Routing\Route and the \Slim\Routing\RouteGroup would check if the resolver is advanced. If so, they call resolveRoute to perform the resolving. Otherwise they do as before.

Note: All the test cases for the callable resolver had been copied and implemented for the advanced callable resolver. Some of them were "triplicated", because two had to throw exceptions and one not.

@coveralls

This comment has been minimized.

Copy link

commented Aug 9, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 1386f93 on adriansuter:patch-callable-resolver into b8d2006 on slimphp:4.x.

@adriansuter adriansuter requested a review from l0gicgate Aug 9, 2019

@l0gicgate
Copy link
Contributor

left a comment

@adriansuter that's a really good solution so we entirely avoid any BC breaks. It's also opt-in for developers to implement which is awesome. Great work

Slim/MiddlewareDispatcher.php Outdated Show resolved Hide resolved
Slim/MiddlewareDispatcher.php Outdated Show resolved Hide resolved
Slim/AdvancedCallableResolver.php Outdated Show resolved Hide resolved

@l0gicgate l0gicgate added the Slim 4 label Aug 9, 2019

@l0gicgate l0gicgate added this to the 4.2.0 milestone Aug 9, 2019

adriansuter and others added 3 commits Aug 10, 2019
@adriansuter

This comment has been minimized.

Copy link
Contributor Author

commented Aug 10, 2019

Okay, there are a lot of changes in the unit tests. I tried to make sure that they test the non-advanced callable resolver as well as the advanced callable resolver.

Two tests did not work as expected. But only if the callable resolver was non-advanced:

  • \Slim\Tests\MiddlewareDispatcherTest::testDeferredResolvedClosureIsBoundToContainer
  • \Slim\Tests\MiddlewareDispatcherTest::testFetchesMiddlewareFromContainer

Any idea why? I think there is something wrong in the \Slim\MiddlewareDispatcher::addDeferred() -> class::handle() method. Just couldn't find the bug.

l0gicgate and others added 4 commits Aug 11, 2019
@adriansuter

This comment has been minimized.

Copy link
Contributor Author

commented Aug 11, 2019

@l0gicgate Merged your PR. Slim is now using the \Slim\Interfaces\AdvancedCallableResolverInterface for the \Slim\CallableResolver by default.

@adriansuter adriansuter changed the title [WIP] 4.x - Add an advanced callable resolver 4.x - Add an advanced callable resolver Aug 11, 2019

@l0gicgate l0gicgate merged commit 88187e7 into slimphp:4.x Aug 11, 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

@adriansuter adriansuter deleted the adriansuter:patch-callable-resolver branch Aug 13, 2019

@l0gicgate l0gicgate referenced this pull request Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.