Skip to content

Conversation

@distantnative
Copy link
Member

@distantnative distantnative commented Feb 4, 2020

Describe the PR

Add $used flag as new last parameter to the route:after hook that represents whether the route was actually used or $this→next() was called inside the route.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Fixed code style issues with CS fixer and composer fix
  • Added in-code documentation (if needed)

@distantnative distantnative added this to the 3.3.4 milestone Feb 4, 2020
@distantnative distantnative self-assigned this Feb 4, 2020
@distantnative distantnative changed the title Pass $used flag to route:after gook #2418 Pass $used flag to route:after hook #2418 Feb 4, 2020
@distantnative
Copy link
Member Author

Damn, something broke...

@distantnative
Copy link
Member Author

@lukasbestle We actually have a small breaking change:
We can't add the new parameter as last one, as ->apply() always modifies/returns the last parameter.

@lukasbestle
Copy link
Member

Hm, that's unfortunate.

Maybe we should instead use the opportunity to replace all those hook arguments ($path, $method, $used and maybe even $route) with one RouteRequest object that carries all the information. That would probably be cleaner in the long run.

Of course this would be something for 3.4 then, but I'd say it would be better to have this breaking-change than to change the param order. The issue with the new param order is that it won't make existing code fail, it would only make it not work properly. If we instead cut down on the arguments, existing hooks will fail hard because they aren't passed enough arguments.

@bastianallgeier bastianallgeier modified the milestones: 3.3.4, 3.4.0 Feb 10, 2020
@bastianallgeier
Copy link
Member

I changed the milestone

@distantnative distantnative mentioned this pull request Apr 14, 2020
4 tasks
@lukasbestle lukasbestle self-assigned this Apr 14, 2020
@lukasbestle lukasbestle added the needs: delay ⏳️ Requires more time, on hold label Apr 14, 2020
@lukasbestle
Copy link
Member

Requires #2541 for a proper implementation.

@bastianallgeier
Copy link
Member

What's the state of this @distantnative & @lukasbestle? Is it compatible with #2541 ?

@lukasbestle
Copy link
Member

@bastianallgeier Now that you have merged the other PR, we can update this to work with the changed structure. I will finalize this PR soon.

@lukasbestle lukasbestle marked this pull request as draft May 8, 2020 14:21
@lukasbestle lukasbestle force-pushed the fix/2418-route-after branch from b8dffcd to 27bd709 Compare May 9, 2020 18:17
@lukasbestle
Copy link
Member

I have now rebased this PR against develop to pull in the changes from #2541.

Because the new $app->apply() implementation now allows modifying an argument that is not the last one, I was able to move the new $used argument to last position for maximum backwards-compatibility.

But because hooks can now request just the arguments they need, the order doesn't matter in the end – it's just relevant for the underlying Router::$afterEach callback where the argument order does matter.

@lukasbestle lukasbestle marked this pull request as ready for review May 9, 2020 18:25
@lukasbestle lukasbestle removed the needs: delay ⏳️ Requires more time, on hold label May 9, 2020
@distantnative
Copy link
Member Author

❤️

I started calling it $used myself, but maybe $final would be the better name.

@lukasbestle
Copy link
Member

@distantnative I agree. Feel free to change it. :)

@bastianallgeier
Copy link
Member

@distantnative @lukasbestle $final sounds more intuitive to me as well.

@lukasbestle
Copy link
Member

@distantnative Could you please make the change? As I'm not the author of the PR, I don't have full access to the Travis build etc.

@distantnative
Copy link
Member Author

Will do

@distantnative distantnative force-pushed the fix/2418-route-after branch from 27bd709 to e29bf3e Compare May 11, 2020 13:41
@distantnative
Copy link
Member Author

Done, ready.

Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

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

👍

@bastianallgeier bastianallgeier merged commit 6b9d879 into develop Jun 23, 2020
@bastianallgeier bastianallgeier deleted the fix/2418-route-after branch June 23, 2020 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants