CakePHP-Bootstrap / cakephp3-bootstrap-helpers

CakePHP 3.x Helpers for Bootstrap 3 and 4.
https://holt59.github.io/cakephp3-bootstrap-helpers/
MIT License
130 stars 79 forks source link

force UrlComparerTrait::_normalize to use GET method #180

Open Erwane opened 5 years ago

Erwane commented 5 years ago

for issue #179

Holt59 commented 5 years ago

Thanks for the PR. Isn't this going to break the opposite case, i.e., if you have a POST URL and you are on a GET one?

Erwane commented 5 years ago

There is no reason a POST only route need UrlComparerTrait for navlinks i thinks.

Maybe in case of ajax url in data-url attribute ...

Another option is to parse RouteCollection and check url only for route allow current method ?

Holt59 commented 5 years ago

I agree with you regarding POST only links in a navigation bar but I would like the UrlComparatorTrait to not be navbar-specific.

Honestly, I don't know why CakePHP has such behaviour... ServerRequest is probably not the right tool for this job, but I have a hard time getting something clean... Comparing CakePHP urls is getting me crazy, this trait was meant to be a small utility tool but it is now probably the most complicated part of the whole helper set.

Erwane commented 4 years ago

Hi. What we need to advance on this PR ?

Holt59 commented 4 years ago

@Erwane A possibility would be to let user specify the method used to compare, with a default to no-method in the UrlComparerTrait (current behavior), but a default to GET in the navbar helper.

This would be retro-compatible, and more flexible for future changes.