Skip to content

Commit

Permalink
Merge pull request #1 from maxmamis/feature/controller-base-routes
Browse files Browse the repository at this point in the history
Controller properly maps rest routes like "post()" to the base controlle...
  • Loading branch information
maxmamis committed Nov 13, 2013
2 parents d0ab1ef + aea27d3 commit c8a036d
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,24 @@ public function loadRoutes($slim) {
$action = strtolower(substr($methodName, 6));
$httpMethod = \Slim\Http\Request::METHOD_DELETE;
}

if (!empty($action)) {
$slim->map("/{$this->base}/{$action}",
array($this, 'preMiddleware'),
array($this, '_runControllerMiddlewares'),
array($this, 'preCallable'),
array($this, $methodName))->via($httpMethod);
$slim->map("/{$this->base}/{$action}(/:param+)",
array($this, 'preMiddleware'),
array($this, '_runControllerMiddlewares'),
array($this, 'preCallable'),
array($this, $methodName))->via($httpMethod);
$action = "/{$action}";
}
else {
$action = "";
}

$slim->map("/{$this->base}{$action}",
array($this, 'preMiddleware'),
array($this, '_runControllerMiddlewares'),
array($this, 'preCallable'),
array($this, $methodName))->via($httpMethod);
$slim->map("/{$this->base}{$action}(/:param+)",
array($this, 'preMiddleware'),
array($this, '_runControllerMiddlewares'),
array($this, 'preCallable'),
array($this, $methodName))->via($httpMethod);
}
}

Expand Down

0 comments on commit c8a036d

Please sign in to comment.