mirror of
https://github.com/Karaka-Management/oms-Search.git
synced 2026-01-11 10:38:40 +00:00
fix search
This commit is contained in:
parent
0c48aa50f8
commit
6056f44884
|
|
@ -45,11 +45,15 @@ final class Installer extends InstallerAbstract
|
||||||
*/
|
*/
|
||||||
public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
|
public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
|
||||||
{
|
{
|
||||||
if (\file_exists(__DIR__ . '/../SearchCommands.php')) {
|
if (!\is_writable(__DIR__ . '/SearchCommands.php')) {
|
||||||
\unlink(__DIR__ . '/../SearchCommands.php');
|
throw new PermissionException(__DIR__ . '/SearchCommands.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
\file_put_contents(__DIR__ . '/../SearchCommands.php', '<?php return [];');
|
if (\is_file(__DIR__ . '/SearchCommands.php')) {
|
||||||
|
\unlink(__DIR__ . '/SearchCommands.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
\file_put_contents(__DIR__ . '/SearchCommands.php', '<?php return [];');
|
||||||
parent::install($app, $info, $cfgHandler);
|
parent::install($app, $info, $cfgHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,30 +72,31 @@ final class Installer extends InstallerAbstract
|
||||||
*/
|
*/
|
||||||
public static function installExternal(ApplicationAbstract $app, array $data) : array
|
public static function installExternal(ApplicationAbstract $app, array $data) : array
|
||||||
{
|
{
|
||||||
if (!\file_exists(__DIR__ . '/../SearchCommands.php')) {
|
if (!\is_file(__DIR__ . '/SearchCommands.php')) {
|
||||||
\file_put_contents(__DIR__ . '/../SearchCommands.php', '<?php return [];');
|
\file_put_contents(__DIR__ . '/SearchCommands.php', '<?php return [];');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\file_exists($data['path'] ?? '')) {
|
if (!\is_file($data['path'] ?? '')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\file_exists(__DIR__ . '/../SearchCommands.php')) {
|
if (!\is_file(__DIR__ . '/SearchCommands.php')) {
|
||||||
throw new PathException(__DIR__ . '/../SearchCommands.php');
|
throw new PathException(__DIR__ . '/SearchCommands.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_writable(__DIR__ . '/../SearchCommands.php')) {
|
if (!\is_writable(__DIR__ . '/SearchCommands.php')) {
|
||||||
throw new PermissionException(__DIR__ . '/../SearchCommands.php');
|
throw new PermissionException(__DIR__ . '/SearchCommands.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
$appRoutes = include __DIR__ . '/../SearchCommands.php';
|
$appRoutes = include __DIR__ . '/SearchCommands.php';
|
||||||
|
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
$moduleRoutes = include $data['path'];
|
$moduleRoutes = include $data['path'];
|
||||||
|
|
||||||
$appRoutes = \array_merge_recursive($appRoutes, $moduleRoutes);
|
$appRoutes = \array_merge_recursive($appRoutes, $moduleRoutes);
|
||||||
|
|
||||||
\file_put_contents(__DIR__ . '/../SearchCommands.php', '<?php return ' . ArrayParser::serializeArray($appRoutes) . ';', \LOCK_EX);
|
\file_put_contents(__DIR__ . '/SearchCommands.php', '<?php return ' . ArrayParser::serializeArray($appRoutes) . ';', \LOCK_EX);
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ final class ApiController extends Controller
|
||||||
parent::__construct($app);
|
parent::__construct($app);
|
||||||
|
|
||||||
$this->router = new WebRouter();
|
$this->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
|
$response
|
||||||
);
|
);
|
||||||
|
|
||||||
if (empty($response->{$data})) {
|
if (empty($response->data)) {
|
||||||
$this->fillJsonRawResponse($request, $response, []);
|
$this->fillJsonRawResponse($request, $response, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
<?php return [
|
|
||||||
'^:help .*$' => [
|
|
||||||
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,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
@ -102,7 +102,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
||||||
$request = new HttpRequest(new HttpUri(''));
|
$request = new HttpRequest(new HttpUri(''));
|
||||||
|
|
||||||
$request->header->account = 1;
|
$request->header->account = 1;
|
||||||
$request->setData('search', ':help file');
|
$request->setData('search', ':help introduction');
|
||||||
|
|
||||||
$this->module->routeSearch($request, $response);
|
$this->module->routeSearch($request, $response);
|
||||||
self::assertGreaterThan(0, \count($response->get('')));
|
self::assertGreaterThan(0, \count($response->get('')));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user