diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index eb1c97e9..794ecde2 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -46,6 +46,8 @@ use OCP\FullTextSearch\IFullTextSearchManager; use OCP\INavigationManager; use OCP\IServerContainer; +use OCP\IURLGenerator; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Throwable; require_once __DIR__ . '/../../vendor/autoload.php'; @@ -54,7 +56,8 @@ class Application extends App implements IBootstrap { - const APP_NAME = 'fulltextsearch'; + const APP_ID = 'fulltextsearch'; + const APP_NAME = 'FullTextSearch'; /** @@ -63,7 +66,7 @@ class Application extends App implements IBootstrap { * @param array $params */ public function __construct(array $params = []) { - parent::__construct(self::APP_NAME, $params); + parent::__construct(self::APP_ID, $params); } @@ -117,8 +120,11 @@ protected function registerNavigation(IServerContainer $container) { return; } - $container->get(INavigationManager::class) - ->add($this->fullTextSearchNavigation()); + try { + $container->get(INavigationManager::class) + ->add($this->fullTextSearchNavigation()); + } catch (RouteNotFoundException $e) { + } } @@ -126,16 +132,15 @@ protected function registerNavigation(IServerContainer $container) { * @return array */ private function fullTextSearchNavigation(): array { - $urlGen = OC::$server->getURLGenerator(); - $navName = OC::$server->getL10N(self::APP_NAME) - ->t('Search'); + /** @var IURLGenerator $urlGen */ + $urlGen = OC::$server->get(IURLGenerator::class); return [ - 'id' => self::APP_NAME, + 'id' => self::APP_ID, 'order' => 5, - 'href' => $urlGen->linkToRoute('fulltextsearch.Navigation.navigate'), - 'icon' => $urlGen->imagePath(self::APP_NAME, 'fulltextsearch.svg'), - 'name' => $navName + 'href' => $urlGen->linkToRoute(self::APP_ID . '.Navigation.navigate'), + 'icon' => $urlGen->imagePath(self::APP_ID, 'fulltextsearch.svg'), + 'name' => 'Search' ]; } diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 09cfdb55..d3c23166 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -76,7 +76,7 @@ public function __construct( IRequest $request, ConfigService $configService, SearchService $searchService, MiscService $miscService ) { - parent::__construct(Application::APP_NAME, $request); + parent::__construct(Application::APP_ID, $request); $this->searchService = $searchService; $this->configService = $configService; $this->miscService = $miscService; diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index cded213e..26627faa 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -75,7 +75,7 @@ public function __construct( IRequest $request, IConfig $config, IFullTextSearchManager $fullTextSearchManager, ConfigService $configService, MiscService $miscService ) { - parent::__construct(Application::APP_NAME, $request); + parent::__construct(Application::APP_ID, $request); $this->config = $config; $this->fullTextSearchManager = $fullTextSearchManager; $this->configService = $configService; @@ -96,7 +96,7 @@ public function navigate(): TemplateResponse { $this->fullTextSearchManager->addJavascriptAPI(); - return new TemplateResponse(Application::APP_NAME, 'navigate', $data); + return new TemplateResponse(Application::APP_ID, 'navigate', $data); } } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index ea5c1bf6..ae96162c 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -71,7 +71,7 @@ public function __construct( IRequest $request, ConfigService $configService, SettingsService $settingsService, MiscService $miscService ) { - parent::__construct(Application::APP_NAME, $request); + parent::__construct(Application::APP_ID, $request); $this->configService = $configService; $this->settingsService = $settingsService; $this->miscService = $miscService; diff --git a/lib/Controller/TemplatesController.php b/lib/Controller/TemplatesController.php index 91577429..33a5772c 100644 --- a/lib/Controller/TemplatesController.php +++ b/lib/Controller/TemplatesController.php @@ -79,7 +79,7 @@ public function __construct( IRequest $request, IConfig $config, ConfigService $configService, ProviderService $providerService, MiscService $miscService ) { - parent::__construct(Application::APP_NAME, $request); + parent::__construct(Application::APP_ID, $request); $this->config = $config; $this->configService = $configService; $this->providerService = $providerService; diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index a799f31d..457ec1aa 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -140,7 +140,7 @@ public function getAppValue(string $key): string { $defaultValue = $this->defaults[$key]; } - return $this->config->getAppValue(Application::APP_NAME, $key, $defaultValue); + return $this->config->getAppValue(Application::APP_ID, $key, $defaultValue); } /** @@ -150,7 +150,7 @@ public function getAppValue(string $key): string { * @param string $value */ public function setAppValue(string $key, string $value) { - $this->config->setAppValue(Application::APP_NAME, $key, $value); + $this->config->setAppValue(Application::APP_ID, $key, $value); } /** @@ -159,7 +159,7 @@ public function setAppValue(string $key, string $value) { * @param string $key */ public function deleteAppValue(string $key) { - $this->config->deleteAppValue(Application::APP_NAME, $key); + $this->config->deleteAppValue(Application::APP_ID, $key); } /** @@ -176,7 +176,7 @@ public function getUserValue(string $key): string { } return $this->config->getUserValue( - $this->userId, Application::APP_NAME, $key, $defaultValue + $this->userId, Application::APP_ID, $key, $defaultValue ); } @@ -189,7 +189,7 @@ public function getUserValue(string $key): string { * @throws PreConditionNotMetException */ public function setUserValue(string $key, string $value) { - $this->config->setUserValue($this->userId, Application::APP_NAME, $key, $value); + $this->config->setUserValue($this->userId, Application::APP_ID, $key, $value); } /** @@ -201,7 +201,7 @@ public function setUserValue(string $key, string $value) { * @return string */ public function getValueForUser(string $userId, string $key) { - return $this->config->getUserValue($userId, Application::APP_NAME, $key); + return $this->config->getUserValue($userId, Application::APP_ID, $key); } /** @@ -214,7 +214,7 @@ public function getValueForUser(string $userId, string $key) { * @throws PreConditionNotMetException */ public function setValueForUser(string $userId, string $key, string $value) { - $this->config->setUserValue($userId, Application::APP_NAME, $key, $value); + $this->config->setUserValue($userId, Application::APP_ID, $key, $value); } diff --git a/lib/Service/MiscService.php b/lib/Service/MiscService.php index 8927fc8d..e606f0ca 100644 --- a/lib/Service/MiscService.php +++ b/lib/Service/MiscService.php @@ -62,7 +62,7 @@ public function __construct(ILogger $logger) { */ public function log(string $message, int $level = 2) { $data = array( - 'app' => Application::APP_NAME, + 'app' => Application::APP_ID, 'level' => $level ); diff --git a/lib/Service/ProviderService.php b/lib/Service/ProviderService.php index 1f2634c9..17cda2de 100644 --- a/lib/Service/ProviderService.php +++ b/lib/Service/ProviderService.php @@ -359,13 +359,13 @@ public function serialize(array $providers): array { * */ public function addJavascriptAPI() { - Util::addStyle(Application::APP_NAME, 'fulltextsearch'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.api'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.settings'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.searchbox'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.result'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.navigation'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1'); + Util::addStyle(Application::APP_ID, 'fulltextsearch'); + Util::addScript(Application::APP_ID, 'fulltextsearch.v1.api'); + Util::addScript(Application::APP_ID, 'fulltextsearch.v1.settings'); + Util::addScript(Application::APP_ID, 'fulltextsearch.v1.searchbox'); + Util::addScript(Application::APP_ID, 'fulltextsearch.v1.result'); + Util::addScript(Application::APP_ID, 'fulltextsearch.v1.navigation'); + Util::addScript(Application::APP_ID, 'fulltextsearch.v1'); } diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 23c9b470..7dd70451 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -83,7 +83,7 @@ public function __construct( * @throws Exception */ public function getForm(): TemplateResponse { - return new TemplateResponse(Application::APP_NAME, 'settings.admin', []); + return new TemplateResponse(Application::APP_ID, 'settings.admin', []); } @@ -91,7 +91,7 @@ public function getForm(): TemplateResponse { * @return string the section ID, e.g. 'sharing' */ public function getSection(): string { - return Application::APP_NAME; + return Application::APP_ID; } diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php index ed8d4877..85f1b858 100644 --- a/lib/Settings/AdminSection.php +++ b/lib/Settings/AdminSection.php @@ -65,7 +65,7 @@ public function __construct(IL10N $l10n, IURLGenerator $urlGenerator) { * {@inheritdoc} */ public function getID(): string { - return Application::APP_NAME; + return Application::APP_ID; } /** @@ -86,6 +86,6 @@ public function getPriority(): int { * {@inheritdoc} */ public function getIcon(): string { - return $this->urlGenerator->imagePath(Application::APP_NAME, 'fulltextsearch_black.svg'); + return $this->urlGenerator->imagePath(Application::APP_ID, 'fulltextsearch_black.svg'); } } diff --git a/templates/navigate.php b/templates/navigate.php index 2cc216c3..6a83d9ea 100644 --- a/templates/navigate.php +++ b/templates/navigate.php @@ -31,8 +31,8 @@ use OCA\FullTextSearch\AppInfo\Application; use OCP\Util; -Util::addScript(Application::APP_NAME, 'navigate'); -Util::addStyle(Application::APP_NAME, 'navigate'); +Util::addScript(Application::APP_ID, 'navigate'); +Util::addStyle(Application::APP_ID, 'navigate'); ?> diff --git a/templates/settings.admin.php b/templates/settings.admin.php index f821fa84..2bab35d1 100644 --- a/templates/settings.admin.php +++ b/templates/settings.admin.php @@ -32,11 +32,11 @@ use OCP\Util; -Util::addScript(Application::APP_NAME, 'admin.elements'); -Util::addScript(Application::APP_NAME, 'admin.settings'); -Util::addScript(Application::APP_NAME, 'admin'); +Util::addScript(Application::APP_ID, 'admin.elements'); +Util::addScript(Application::APP_ID, 'admin.settings'); +Util::addScript(Application::APP_ID, 'admin'); -Util::addStyle(Application::APP_NAME, 'admin'); +Util::addStyle(Application::APP_ID, 'admin'); ?>