From daa8b86da58552d4ef41bf68f09046e55737ec07 Mon Sep 17 00:00:00 2001 From: Michiel Date: Sat, 5 May 2012 15:36:06 +0200 Subject: [PATCH 1/2] Modified the handles method to allow for multiples handles per bundle 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 --- laravel/bundle.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/laravel/bundle.php b/laravel/bundle.php index 2259228ee36..f3c519f38a8 100644 --- a/laravel/bundle.php +++ b/laravel/bundle.php @@ -191,9 +191,35 @@ public static function handles($uri) foreach (static::$bundles as $key => $value) { - if (isset($value['handles']) and starts_with($uri, $value['handles'].'/')) + + if (isset($value['handles']) ) { - return $key; + // Do we have multiple handles in an array? + if (is_array($value['handles']) ) + { + // Let's see if one of them matches the uri + foreach($value['handles'] as $handles) + { + + if(starts_with($uri, $handles.'/')) + { + // replace the array with a string with the matching handles and return the key + static::$bundles[$key]['handles'] = $handles; + return $key; + } + } + + } + // Original code for single handles + else + { + if(starts_with($uri, $value['handles'].'/')) + { + return $key; + } + + } + } } From 021d6a59afb60f3a2d03cab66a07b6fb67c845bd Mon Sep 17 00:00:00 2001 From: Michiel Date: Sat, 5 May 2012 17:06:17 +0200 Subject: [PATCH 2/2] Shortened the code based on feedback from ProgerXP https://github.com/laravel/laravel/pull/632#issuecomment-5527622 --- laravel/bundle.php | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/laravel/bundle.php b/laravel/bundle.php index f3c519f38a8..69e62d3c1a2 100644 --- a/laravel/bundle.php +++ b/laravel/bundle.php @@ -191,35 +191,18 @@ public static function handles($uri) foreach (static::$bundles as $key => $value) { - - if (isset($value['handles']) ) - { - // Do we have multiple handles in an array? - if (is_array($value['handles']) ) - { - // Let's see if one of them matches the uri - foreach($value['handles'] as $handles) - { - - if(starts_with($uri, $handles.'/')) - { - // replace the array with a string with the matching handles and return the key - static::$bundles[$key]['handles'] = $handles; - return $key; - } - } - - } - // Original code for single handles - else + if (isset($value['handles'])) + { + // Let's see if one of them matches the uri + foreach ((array) $value['handles'] as $handles) { - if(starts_with($uri, $value['handles'].'/')) + if (starts_with($uri, $handles.'/')) { + // replace the array with a string with the matching handles and return the key + static::$bundles[$key]['handles'] = $handles; return $key; } - } - } }