mirror of
https://github.com/silverstripe/silverstripe-restfulserver
synced 2024-10-22 14:05:58 +02:00
added findClassNameEndpoint method, replaced getEndpointAlias()
This commit is contained in:
parent
d27156e890
commit
7eb95693f7
@ -186,15 +186,10 @@ class RestfulServer extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(HTTPRequest $request)
|
public function index(HTTPRequest $request)
|
||||||
{
|
{
|
||||||
$endpoint = $request->param('ClassName');
|
$className = $this->unsanitiseClassName($this->findClassNameEndpoint($request->param('ClassName')));
|
||||||
$className = $this->unsanitiseClassName($endpoint);
|
|
||||||
$id = $request->param('ID') ?: null;
|
$id = $request->param('ID') ?: null;
|
||||||
$relation = $request->param('Relation') ?: null;
|
$relation = $request->param('Relation') ?: null;
|
||||||
|
|
||||||
if ($alias = $this->getEndpointAlias($endpoint)) {
|
|
||||||
$className = $alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check input formats
|
// Check input formats
|
||||||
if (!class_exists($className)) {
|
if (!class_exists($className)) {
|
||||||
return $this->notFound();
|
return $this->notFound();
|
||||||
@ -905,13 +900,15 @@ class RestfulServer extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Checks if given $endpoint maps to an object in endpoint_aliases, else simply return $endpoint as is
|
||||||
|
*
|
||||||
* @param $endpoint
|
* @param $endpoint
|
||||||
* @return null | string
|
* @return null | string
|
||||||
*/
|
*/
|
||||||
protected function getEndpointAlias($endpoint)
|
protected function findClassNameEndpoint($endpoint)
|
||||||
{
|
{
|
||||||
$aliases = self::config()->get('endpoint_aliases');
|
$aliases = self::config()->get('endpoint_aliases');
|
||||||
|
|
||||||
return $aliases[$endpoint] ?? null;
|
return $aliases[$endpoint] ?? $endpoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user