mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
use id instead of resourceId
This commit is contained in:
parent
5496ca234b
commit
2662c4c61b
2 changed files with 3 additions and 13 deletions
|
|
@ -122,14 +122,13 @@ class RouteConfig {
|
|||
foreach ($resources as $resource => $config) {
|
||||
|
||||
// the url parameter used as id to the resource
|
||||
$resourceId = $this->buildResourceId($resource);
|
||||
foreach($actions as $action) {
|
||||
$url = $config['url'];
|
||||
$method = $action['name'];
|
||||
$verb = isset($action['verb']) ? strtoupper($action['verb']) : 'GET';
|
||||
$collectionAction = isset($action['on-collection']) ? $action['on-collection'] : false;
|
||||
if (!$collectionAction) {
|
||||
$url = $url . '/' . $resourceId;
|
||||
$url = $url . '/{id}';
|
||||
}
|
||||
if (isset($action['url-postfix'])) {
|
||||
$url = $url . '/' . $action['url-postfix'];
|
||||
|
|
@ -168,15 +167,6 @@ class RouteConfig {
|
|||
return $this->underScoreToCamelCase($action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the id used in the url part o the route url
|
||||
* @param string $resource
|
||||
* @return string
|
||||
*/
|
||||
private function buildResourceId($resource) {
|
||||
return '{' . $this->underScoreToCamelCase($resource) . 'Id}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Underscored strings are converted to camel case strings
|
||||
* @param string $str
|
||||
|
|
|
|||
|
|
@ -78,14 +78,14 @@ class RoutingTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$routes = array('resources' => array('account' => array('url' => '/accounts')));
|
||||
|
||||
$this->assertResource($routes, 'account', '/accounts', 'AccountController', 'accountId');
|
||||
$this->assertResource($routes, 'account', '/accounts', 'AccountController', 'id');
|
||||
}
|
||||
|
||||
public function testResourceWithUnderScoreName()
|
||||
{
|
||||
$routes = array('resources' => array('admin_accounts' => array('url' => '/admin/accounts')));
|
||||
|
||||
$this->assertResource($routes, 'admin_accounts', '/admin/accounts', 'AdminAccountsController', 'adminAccountsId');
|
||||
$this->assertResource($routes, 'admin_accounts', '/admin/accounts', 'AdminAccountsController', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue