From 6056f44884126f104fbd7e5868baaa883b9d87f7 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 29 Sep 2023 16:42:41 +0000 Subject: [PATCH] fix search --- Admin/Installer.php | 29 ++++++----- Controller/ApiController.php | 4 +- SearchCommands.php | 66 -------------------------- tests/Controller/ApiControllerTest.php | 2 +- 4 files changed, 20 insertions(+), 81 deletions(-) delete mode 100644 SearchCommands.php diff --git a/Admin/Installer.php b/Admin/Installer.php index ec27d41..faa5c52 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -45,11 +45,15 @@ final class Installer extends InstallerAbstract */ public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void { - if (\file_exists(__DIR__ . '/../SearchCommands.php')) { - \unlink(__DIR__ . '/../SearchCommands.php'); + if (!\is_writable(__DIR__ . '/SearchCommands.php')) { + throw new PermissionException(__DIR__ . '/SearchCommands.php'); } - \file_put_contents(__DIR__ . '/../SearchCommands.php', 'router = new WebRouter(); - $this->router->importFromFile(__DIR__ . '/../SearchCommands.php'); + $this->router->importFromFile(__DIR__ . '/../Admin/SearchCommands.php'); } /** @@ -70,7 +70,7 @@ final class ApiController extends Controller $response ); - if (empty($response->{$data})) { + if (empty($response->data)) { $this->fillJsonRawResponse($request, $response, []); } } diff --git a/SearchCommands.php b/SearchCommands.php deleted file mode 100644 index 33afa76..0000000 --- a/SearchCommands.php +++ /dev/null @@ -1,66 +0,0 @@ - [ - 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, - 'permission' => [ - 'module' => 'Help', - 'type' => 2, - 'state' => 2, - ], - ], - ], - '^:help :user .*$' => [ - 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, - 'permission' => [ - 'module' => 'Help', - 'type' => 2, - 'state' => 2, - ], - ], - ], - '^:help :dev .*$' => [ - 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, - 'permission' => [ - 'module' => 'Help', - 'type' => 2, - 'state' => 3, - ], - ], - ], - '^:help :module .*$' => [ - 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, - 'permission' => [ - 'module' => 'Help', - 'type' => 2, - 'state' => 2, - ], - ], - ], - '^:goto .*$' => [ - 0 => [ - 'dest' => '\Modules\Navigation\Controller\SearchController:searchGoto', - 'verb' => 16, - 'permission' => [ - 'module' => 'Navigation', - 'type' => 2, - ], - ], - ], - '^:tag .*$' => [ - 0 => [ - 'dest' => '\Modules\Tasks\Controller\SearchController:searchTag', - 'verb' => 16, - 'permission' => [ - 'module' => 'Tasks', - 'type' => 2, - ], - ], - ], -]; \ No newline at end of file diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index c41cdc2..8e927c6 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -102,7 +102,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $request = new HttpRequest(new HttpUri('')); $request->header->account = 1; - $request->setData('search', ':help file'); + $request->setData('search', ':help introduction'); $this->module->routeSearch($request, $response); self::assertGreaterThan(0, \count($response->get('')));