-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Multiple handles for bundles #632
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
Conversation
… in the bundle configuration return array( 'blog' => array('handles' => array('blog', 'my_blog') ), ); The blog-bundle will now be revoked for mydomain.com/blog as well as mydomain.com/my_blog The original configuration with a single string, can still be used as well
Hmm, this looks nice. You could however shorten your code by eliminating the 'else' branch like this:
|
+1 for adding this to the core, please. Use case: system for making multiple storefronts that share a lot of code, but have some site-specific code. One approach would be to put each storefront into a bundle, but then it would have to handle multiple URI roots, such as mystore/products, mystore/basket, mystore/checkout etc. |
👍 |
What happens when you use (:bundle). In a route with this? I thought that came from the 'handles' param. |
@daylerees: I had looked into this when I coded the new feature. So far I haven't had situations where routes with (:bundle) weren't set properly. I've been using this code for about 3 weeks now and haven't experience any errors with it. Also with v3.2. That off course doesn't mean that the code is bullet-proof. Perhaps it's a good idea if a bunch of people try out the code in their project, to see if it breaks anything. |
This is huge! Please merge it :) |
good one |
+1 |
@mileswebdesign wrote:
Has anyone else had a chance to play with this, especially using |
Seems to break in the Router class. Can we add something like this ?
|
@yuters Can you post your code (the actual route) that breaks the router class in your setup? That way we have something to test with. |
Of course, but I'm really just starting to work with this framework. If I create a simple admin bundle, adding this to application/bundles.php :
and in my admin bundle, I have a simple routes.php
everything works fine. But if I add 'auto' => true in the application/bundles.php for the admin, I get this error (array to string conversion) in the Router class. But maybe I'm doing something wrong here? The fix I tried to make returns a 404 for cms/ |
How about this?
|
Although it works for me now... maybe using \URI::current() isn't such a good idea. Maybe there's a way to call the Router register method again for each handles? |
@mileswebdesign it looks like there's still an unresolved issue using "(:bundle)" in a route when the bundle is auto loaded? |
Where are we at on this? Still outstanding issues? |
Hi guys, sorry I just returned from holidays and haven't had a chance to look into this request further. I have an idea of how to solve the issue raised and hope to come up with a solution by this weekend. |
Any progress with this one? Thanks! |
Will address this issue in next major release. Focusing mainly on bug fixes for Laravel 3.x at this point. |
+1 |
I found a case where I need this ability also. So +1 from me too. |
OK, we have a need to this too however not all routes work when I make this change after applying this patch: When I change my bundles.php entry from: 'atable' => array('handles' => 'contacts')), to 'atable' => array('handles' => array('contacts','messages')), I receive the following error on some of my routes (some routes work and some don't!): Unhandled Exception Message: Array to string conversion /home2/xxx/xx/laravel/routing/router.php on line 209 #0 /home2/xxx/xx/laravel/laravel.php(40): Laravel\Error::native(8, 'Array to string...', '/home2/xxx...', 209) So should I raise this as a separate issue? |
@tester5 please do not raise a separate issue, it's a problem with this patch and not how laravel works at present. |
ok no worries, will track this pull request. This issue only presents itself when I use the array notation when trying to register more than one handle. and strangely, some routes still work and now some don't :-0 |
Hi Taylor,
I made a change to the bundle class, which allows one to set multiple handles for a bundle. It's a simple change, that won't add a lot of extra overhead, but makes the routing of bundles a bit more flexible.
A practical example would be when you have two separate blogs on your website (for example in different languages). They would both use the same blog bundle, but serve up different content based on the URI. With this addition you don't have to include a reference to 'blog' anymore like /blog/myfirstblog and /blog/mysecondblog. Instead you can simply configure multiple handles and use /myfirstblog and /mysecondblog directly. Looks a bit cleaner, I think.
Hope you like it :)