Skip to content

Commit 43467c5

Browse files
jessevzjessevz
andauthored
Fixed classnames by removing the package from the name (#1987)
Co-authored-by: jessevz <jesse.van.zutphen@nfi.nl>
1 parent bcd46ca commit 43467c5

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/inc/apiv2/common/AbstractBaseAPI.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,9 @@ final protected function getObjectTypeName(mixed $obj): string {
421421
}
422422

423423
/* Use the API class Name as type identifier written in camelCase*/
424-
return lcfirst(substr($apiClass, 0, -3));
424+
$name_parts = explode('\\', $apiClass);
425+
$name = end($name_parts);
426+
return lcfirst(substr($name, 0, -3));
425427
}
426428

427429
/**

src/inc/apiv2/common/openAPISchema.routes.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
/* Quirk to receive className, since it is hidden in a protected variable */
103103
$reflectionOfRoute = new \ReflectionObject($route);
104104
$protectedCallable = $reflectionOfRoute->getProperty('callable');
105-
$protectedCallable->setAccessible(true);
106105
$reflectionCallable = ($protectedCallable->getValue($route));
107106

108107
/* Assume only one method per route call */
@@ -123,9 +122,10 @@
123122
$class = new $apiClassName($app->getContainer());
124123

125124
if (!($class instanceof AbstractModelAPI)) {
126-
$name = $class::class;
125+
$name_parts = explode('\\', $class::class);
126+
$name = end($name_parts);
127127
$apiMethod = ($apiMethod == "processPost" && $name != "ImportFileHelperAPI") ? "actionPost" : $apiMethod;
128-
$reflectionApiMethod = new ReflectionMethod($name, $apiMethod);
128+
$reflectionApiMethod = new ReflectionMethod($class::class, $apiMethod);
129129
$paths[$path][$method]["description"] = OpenAPISchemaUtils::parsePhpDoc($reflectionApiMethod->getDocComment());
130130
$parameters = $class->getCreateValidFeatures();
131131
$properties = OpenAPISchemaUtils::makeProperties($parameters);
@@ -135,7 +135,7 @@
135135
"properties" => $properties,
136136
];
137137
if ($method == "post") {
138-
$reflectionMethodFormFields = new ReflectionMethod($name, "getFormFields");
138+
$reflectionMethodFormFields = new ReflectionMethod($class::class, "getFormFields");
139139
$bodyDescription = OpenAPISchemaUtils::parsePhpDoc($reflectionMethodFormFields->getDocComment());
140140
$paths[$path][$method]["requestBody"] = [
141141
"description" => $bodyDescription,
@@ -188,7 +188,8 @@
188188

189189
/* Quick to find out if single parameter object is used */
190190
$singleObject = ((strstr($path, '/{id:')) !== false);
191-
$name = substr($class->getDBAClass(), 4);
191+
$name_parts = explode('\\', $class->getDBAClass());
192+
$name = end($name_parts);
192193
$uri = $class->getBaseUri();
193194

194195
$isRelation = (strstr($path, "/relationships/")) !== false;

0 commit comments

Comments
 (0)