Skip to content

Commit 63aa6b5

Browse files
committed
fixup! feat(AppFramework): Add Route attribute
1 parent 91bdf72 commit 63aa6b5

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

lib/private/Route/Router.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ protected function fixLegacyRootName(string $routeName): string {
447447
private function getAttributeRoutes(string $app): array {
448448
$routes = [];
449449

450-
if ($app === "core") {
451-
$appControllerPath = __DIR__ . "/../../../core/Controller";
452-
$appNameSpace = "OC\\Core";
450+
if ($app === 'core') {
451+
$appControllerPath = __DIR__ . '/../../../core/Controller';
452+
$appNameSpace = 'OC\\Core';
453453
} else {
454-
$appControllerPath = \OC_App::getAppPath($app) . "/lib/Controller";
454+
$appControllerPath = \OC_App::getAppPath($app) . '/lib/Controller';
455455
$appNameSpace = App::buildAppNamespace($app);
456456
}
457457

@@ -461,26 +461,26 @@ private function getAttributeRoutes(string $app): array {
461461

462462
$dir = new DirectoryIterator($appControllerPath);
463463
foreach ($dir as $file) {
464-
if (!str_ends_with($file->getPathname(), "Controller.php")) {
464+
if (!str_ends_with($file->getPathname(), 'Controller.php')) {
465465
continue;
466466
}
467467

468-
$class = new ReflectionClass($appNameSpace . "\\Controller\\" . basename($file->getPathname(), ".php"));
468+
$class = new ReflectionClass($appNameSpace . '\\Controller\\' . basename($file->getPathname(), '.php'));
469469

470470
foreach ($class->getMethods() as $method) {
471471
foreach ($method->getAttributes() as $attribute) {
472-
if ($attribute->getName() !== "OCP\AppFramework\Http\Attribute\Route" &&
473-
$attribute->getName() !== "OCP\AppFramework\Http\Attribute\ApiRoute" &&
474-
$attribute->getName() !== "OCP\AppFramework\Http\Attribute\FrontpageRoute") {
472+
if ($attribute->getName() !== 'OCP\AppFramework\Http\Attribute\Route' &&
473+
$attribute->getName() !== 'OCP\AppFramework\Http\Attribute\ApiRoute' &&
474+
$attribute->getName() !== 'OCP\AppFramework\Http\Attribute\FrontpageRoute') {
475475
continue;
476476
}
477477

478478
/** @var RouteAttribute $route */
479479
$route = $attribute->newInstance();
480480

481481
$serializedRoute = $route->toArray();
482-
// Remove "Controller" suffix
483-
$serializedRoute["name"] = substr($class->getShortName(), 0, -10) . "#" . $method->getName();
482+
// Remove 'Controller' suffix
483+
$serializedRoute['name'] = substr($class->getShortName(), 0, -10) . '#' . $method->getName();
484484

485485
$key = $route->getType();
486486

0 commit comments

Comments
 (0)