CLI: API templates
This commit is contained in:
@@ -248,7 +248,7 @@ abstract class Request {
|
||||
|
||||
// Check for permission
|
||||
$req = new \Core\API\Permission\Check($this->context);
|
||||
$this->success = $req->execute(array("method" => self::getEndpoint()));
|
||||
$this->success = $req->execute(["method" => self::getEndpoint()]);
|
||||
$this->lastError = $req->getLastError();
|
||||
if (!$this->success) {
|
||||
return false;
|
||||
@@ -336,11 +336,19 @@ abstract class Request {
|
||||
return null;
|
||||
}
|
||||
|
||||
$isNestedAPI = $reflectionClass->getParentClass()->getName() !== Request::class;
|
||||
$parentClass = $reflectionClass->getParentClass();
|
||||
if ($parentClass === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$isNestedAPI = $parentClass->getName() !== Request::class;
|
||||
if (!$isNestedAPI) {
|
||||
# e.g. /api/stats or /api/info
|
||||
$methodName = $reflectionClass->getShortName();
|
||||
return $prefix . lcfirst($methodName);
|
||||
} else if ($parentClass->getName() === \TestRequest::class) {
|
||||
$methodName = $reflectionClass->getShortName();
|
||||
return $prefix . "/e2e-test/" . lcfirst($methodName);
|
||||
} else {
|
||||
# e.g. /api/user/login
|
||||
$methodClass = $reflectionClass;
|
||||
@@ -348,6 +356,10 @@ abstract class Request {
|
||||
while (!endsWith($nestedClass->getName(), "API")) {
|
||||
$methodClass = $nestedClass;
|
||||
$nestedClass = $nestedClass->getParentClass();
|
||||
|
||||
if (!$nestedClass) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$nestedAPI = substr(lcfirst($nestedClass->getShortName()), 0, -3);
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Core\API {
|
||||
if ($count === 1) {
|
||||
return $string;
|
||||
} else {
|
||||
return "the next $count ${string}s";
|
||||
return "the next $count {$string}s";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace Core\API\User {
|
||||
|
||||
public function __construct(Context $context, $externalCall = false) {
|
||||
parent::__construct($context, $externalCall,
|
||||
self::getPaginationParameters(['id', 'name', 'fullName', 'email', 'groups', 'registeredAt', 'confirmed'],
|
||||
self::getPaginationParameters(['id', 'name', 'fullName', 'email', 'groups', 'registeredAt', 'active', 'confirmed'],
|
||||
'id', 'asc')
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user