-
Notifications
You must be signed in to change notification settings - Fork 577
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
[2.x] enh: Add Twill Route facade to preserve singleton()
method
#1964
Conversation
singleton()
methodsingleton()
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @pboivin, thank you!
I feel we should name this TwillRouter instead? |
We also already have the TwillRoutes facade. We could just use that for Twill specific routes? <?php
use Illuminate\Support\Facades\Route;
use A17\Twill\Facades\TwillRoutes;
Route::get('bar');
Route::singleton('some-singleton');
TwillRoutes::module('pages');
TwillRoutes::singleton('menuLinks'); We can add this to 2.x as well, but in 3.x this should be the default to use our facade. |
Hey @haringsrob, thanks for the feedback! A few thoughts:
|
Hey, I believe that with this approach we are overwriting the singleton method provided by Laravel, so we cannot use that and the Twill singleton together. I want to avoid confusion and leave that functionality intact, that is why the prefixing in the current macro was done. The same goes for why I opt to reuse TwillRoutes instead of a new Routes facade, I know it is already name spaced, but the (when mixed (which I think would not happen much)) would require to make an alias. And here again, this may cause confusion when writing routes as in accidentally taking the wrong facade. While it does not happen much, I do take from this experience that using to generic macro's may lead to conflicts in the future, and for this we better take things into our own hands to avoid this from happening again. Sorry if I am misunderstanding, if so, please let me know. |
It makes sense, thanks for the precision. I guess the main point I'm thinking of is that switching to a |
This PR adds a
Route
facade in Twill. The facade is equivalent toIlluminate\Support\Facades\Route
, and adds asingleton()
static method as an alias for thetwillSingleton()
macro (renamed in 2.12.0).This offers an alternative migration path on
2.x
, which is to useA17\Twill\Facades\Route
withinroutes/admin.php
.ref: #1961