Skip to content

Commit

Permalink
resouceId
Browse files Browse the repository at this point in the history
  • Loading branch information
zweifisch committed Dec 15, 2013
1 parent 5206f6b commit 69ac3a3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions zf/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,24 @@ public function resource()
$fsPath = implode('/', $args);
$name = array_pop($args);
$path = implode('', array_map(function($segment) {
return '/' . $segment . '/:' . $segment;
return '/' . $segment . '/:' . $segment . 'Id';
}, $args)) . '/' . $name;
$id = $name . 'Id';
$routes = [
['GET' , "$path" , ["$fsPath/index"]],
['GET' , "$path/new" , ["$fsPath/new"]],
['POST' , "$path" , ["$fsPath/create"]],
['GET' , "$path/:$name" , ["$fsPath/show"]],
['GET' , "$path/:$name/edit" , ["$fsPath/edit"]],
['PUT' , "$path/:$name" , ["$fsPath/update"]],
['PATCH' , "$path/:$name" , ["$fsPath/modify"]],
['DELETE' , "$path/:$name" , ["$fsPath/destroy"]],
['GET' , "$path/:$id" , ["$fsPath/show"]],
['GET' , "$path/:$id/edit" , ["$fsPath/edit"]],
['PUT' , "$path/:$id" , ["$fsPath/update"]],
['PATCH' , "$path/:$id" , ["$fsPath/modify"]],
['DELETE' , "$path/:$id" , ["$fsPath/destroy"]],
];
if ($customMethods)
{
foreach($customMethods as $method)
{
$routes[] = ['POST', "/$path/:$name/$method", ["$fsPath/$method"]];
$routes[] = ['POST', "/$path/:$id/$method", ["$fsPath/$method"]];
}
}
$this->router->bulk($routes);
Expand Down

0 comments on commit 69ac3a3

Please sign in to comment.