Allow ocs/v2.php/cloud/... routes
One of the possibilities of the old OCS API is that you can define the url yourself. This PR makes this possible again by adding an optional root elemenet to the route. Routes are thus: .../ocs/v2.php/<root>/<url> By default <root> = apps/<app> This will allow for example the provisioning API etc to be in ../ovs/v2/php/cloud/users
This commit is contained in:
parent
70eef2a82e
commit
63f6d2d558
|
@ -86,7 +86,13 @@ class RouteConfig {
|
||||||
$postfix = $ocsRoute['postfix'];
|
$postfix = $ocsRoute['postfix'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = $ocsRoute['url'];
|
if (isset($ocsRoute['root'])) {
|
||||||
|
$root = $ocsRoute['root'];
|
||||||
|
} else {
|
||||||
|
$root = '/apps/'.$this->appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $root . $ocsRoute['url'];
|
||||||
$verb = isset($ocsRoute['verb']) ? strtoupper($ocsRoute['verb']) : 'GET';
|
$verb = isset($ocsRoute['verb']) ? strtoupper($ocsRoute['verb']) : 'GET';
|
||||||
|
|
||||||
$split = explode('#', $name, 2);
|
$split = explode('#', $name, 2);
|
||||||
|
|
|
@ -154,7 +154,7 @@ class Router implements IRouter {
|
||||||
|
|
||||||
// Also add the OCS collection
|
// Also add the OCS collection
|
||||||
$collection = $this->getCollection($app.'.ocs');
|
$collection = $this->getCollection($app.'.ocs');
|
||||||
$collection->addPrefix('/ocsapp/apps/' . $app);
|
$collection->addPrefix('/ocsapp');
|
||||||
$this->root->addCollection($collection);
|
$this->root->addCollection($collection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class RoutingTest extends \Test\TestCase
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/folders/{folderId}/open', 'FoldersController', 'open');
|
$this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSimpleRouteWithMissingVerb()
|
public function testSimpleRouteWithMissingVerb()
|
||||||
|
@ -42,7 +42,7 @@ class RoutingTest extends \Test\TestCase
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/folders/{folderId}/open', 'FoldersController', 'open');
|
$this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSimpleRouteWithLowercaseVerb()
|
public function testSimpleRouteWithLowercaseVerb()
|
||||||
|
@ -60,7 +60,7 @@ class RoutingTest extends \Test\TestCase
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open');
|
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSimpleRouteWithRequirements()
|
public function testSimpleRouteWithRequirements()
|
||||||
|
@ -78,7 +78,7 @@ class RoutingTest extends \Test\TestCase
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', ['something']);
|
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', ['something']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSimpleRouteWithDefaults()
|
public function testSimpleRouteWithDefaults()
|
||||||
|
@ -97,7 +97,7 @@ class RoutingTest extends \Test\TestCase
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']);
|
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSimpleRouteWithPostfix()
|
public function testSimpleRouteWithPostfix()
|
||||||
|
@ -115,7 +115,7 @@ class RoutingTest extends \Test\TestCase
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something');
|
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,7 +175,7 @@ class RoutingTest extends \Test\TestCase
|
||||||
['name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
|
['name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
|
||||||
]];
|
]];
|
||||||
|
|
||||||
$this->assertSimpleOCSRoute($routes, 'admin_folders.open_current', 'DELETE', '/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent');
|
$this->assertSimpleOCSRoute($routes, 'admin_folders.open_current', 'DELETE', '/apps/app1/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testResource()
|
public function testResource()
|
||||||
|
|
Loading…
Reference in New Issue