Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
This is a fix for issue #74 that will allow both the original method …
Browse files Browse the repository at this point in the history
…of adding routes and the new map method to coexist without throwing an error.

Before the fix, using:

Macaw::get('/api/pages/partial/(:num)', 'Mynamespace\API\Pages@getPartial');
Macaw::put('/api/pages/partial/(:num)', 'Mynamespace\API\Pages@updatePartial');

would throw an error with when it tried to evaluate the maps array (which is null if you are not using the map function).
  • Loading branch information
Steve Hawes committed Jan 8, 2018
1 parent 34f08a6 commit 502ed52
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Macaw.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function dispatch(){
}

if (preg_match('#^' . $route . '$#', $uri, $matched)) {
if (self::$methods[$pos] == $method || self::$methods[$pos] == 'ANY' || in_array($method, self::$maps[$pos])) {
if (self::$methods[$pos] == $method || self::$methods[$pos] == 'ANY' || (!empty(self::$maps[$pos]) && in_array($method, self::$maps[$pos]))) {
$found_route = true;

// Remove $matched[0] as [1] is the first parameter.
Expand Down

0 comments on commit 502ed52

Please sign in to comment.