Skip to content

Commit a9ed790

Browse files
committed
fixup! feat(routing): Support new Route attribute
1 parent 70f6760 commit a9ed790

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

generate-spec

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,15 @@ foreach ($controllers as $controllerName => $stmts) {
272272
/** @var AttributeGroup $attrGroup */
273273
foreach ($classMethod->attrGroups as $attrGroup) {
274274
foreach ($attrGroup->attrs as $attr) {
275-
if ($attr->name->getLast() !== "Route") {
275+
if ($attr->name->getLast() !== "Route" && $attr->name->getLast() !== "ApiRoute" && $attr->name->getLast() !== "FrontpageRoute") {
276276
continue;
277277
}
278278

279-
$key = null;
279+
$key = match ($attr->name->getLast()) {
280+
"Route" => null,
281+
"ApiRoute" => "ocs",
282+
"FrontpageRoute" => "routes",
283+
};
280284
$args = [
281285
"name" => $name,
282286
];
@@ -286,14 +290,18 @@ foreach ($controllers as $controllerName => $stmts) {
286290
if ($arg->name !== null) {
287291
$argName = $arg->name->name;
288292
} else {
289-
$argName = ["type", "verb", "url", "requirements", "defaults", "root", "postfix"][$i];
293+
$argNames = ["verb", "url", "requirements", "defaults", "root", "postfix"];
294+
if ($attr->name->getLast() === "Route") {
295+
array_unshift($argNames, "type");
296+
}
297+
$argName = $argNames[$i];
290298
}
291299

292300
if ($argName === "type" && $arg->value instanceof ClassConstFetch) {
293301
$type = $arg->value->name->name;
294302
$key = match ($type) {
295-
"TYPE_FRONTPAGE" => "routes",
296303
"TYPE_API" => "ocs",
304+
"TYPE_FRONTPAGE" => "routes",
297305
default => Logger::panic($name, "Unknown Route type: " . $type),
298306
};
299307
continue;

0 commit comments

Comments
 (0)