Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2021-07-20 02:04:52 +0300
committerMaxence Lange <maxence@artificial-owl.com>2021-07-20 02:04:52 +0300
commita4d8572407ccb309e1277f0203594a9a7fbc2920 (patch)
treeea0428d27127a9263eff02c54234a20ccc8c627e
parent3ae181636d8a50525360b12d8ca7aa9fe481badd (diff)
better load of libs
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--lib/AppInfo/Application.php27
-rw-r--r--lib/Controller/ApiController.php2
-rw-r--r--lib/Controller/NavigationController.php4
-rw-r--r--lib/Controller/SettingsController.php2
-rw-r--r--lib/Controller/TemplatesController.php2
-rw-r--r--lib/Service/ConfigService.php14
-rw-r--r--lib/Service/MiscService.php2
-rw-r--r--lib/Service/ProviderService.php14
-rw-r--r--lib/Settings/Admin.php4
-rw-r--r--lib/Settings/AdminSection.php4
-rw-r--r--templates/navigate.php4
-rw-r--r--templates/settings.admin.php8
12 files changed, 46 insertions, 41 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index eb1c97e..794ecde 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -46,6 +46,8 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext;
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 @@ require_once __DIR__ . '/../../vendor/autoload.php';
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 @@ class Application extends App implements IBootstrap {
return;
}
- $container->get(INavigationManager::class)
- ->add($this->fullTextSearchNavigation());
+ try {
+ $container->get(INavigationManager::class)
+ ->add($this->fullTextSearchNavigation());
+ } catch (RouteNotFoundException $e) {
+ }
}
@@ -126,16 +132,15 @@ class Application extends App implements IBootstrap {
* @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 09cfdb5..d3c2316 100644
--- a/lib/Controller/ApiController.php
+++ b/lib/Controller/ApiController.php
@@ -76,7 +76,7 @@ class ApiController extends Controller {
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 cded213..26627fa 100644
--- a/lib/Controller/NavigationController.php
+++ b/lib/Controller/NavigationController.php
@@ -75,7 +75,7 @@ class NavigationController extends Controller {
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 @@ class NavigationController extends Controller {
$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 ea5c1bf..ae96162 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -71,7 +71,7 @@ class SettingsController extends Controller {
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 9157742..33a5772 100644
--- a/lib/Controller/TemplatesController.php
+++ b/lib/Controller/TemplatesController.php
@@ -79,7 +79,7 @@ class TemplatesController extends Controller {
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 a799f31..457ec1a 100644
--- a/lib/Service/ConfigService.php
+++ b/lib/Service/ConfigService.php
@@ -140,7 +140,7 @@ class ConfigService {
$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 @@ class ConfigService {
* @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 @@ class ConfigService {
* @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 @@ class ConfigService {
}
return $this->config->getUserValue(
- $this->userId, Application::APP_NAME, $key, $defaultValue
+ $this->userId, Application::APP_ID, $key, $defaultValue
);
}
@@ -189,7 +189,7 @@ class ConfigService {
* @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 @@ class ConfigService {
* @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 @@ class ConfigService {
* @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 8927fc8..e606f0c 100644
--- a/lib/Service/MiscService.php
+++ b/lib/Service/MiscService.php
@@ -62,7 +62,7 @@ class MiscService {
*/
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 1f2634c..17cda2d 100644
--- a/lib/Service/ProviderService.php
+++ b/lib/Service/ProviderService.php
@@ -359,13 +359,13 @@ class ProviderService implements IProviderService {
*
*/
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 23c9b47..7dd7045 100644
--- a/lib/Settings/Admin.php
+++ b/lib/Settings/Admin.php
@@ -83,7 +83,7 @@ class Admin implements ISettings {
* @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 @@ class Admin implements ISettings {
* @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 ed8d487..85f1b85 100644
--- a/lib/Settings/AdminSection.php
+++ b/lib/Settings/AdminSection.php
@@ -65,7 +65,7 @@ class AdminSection implements IIconSection {
* {@inheritdoc}
*/
public function getID(): string {
- return Application::APP_NAME;
+ return Application::APP_ID;
}
/**
@@ -86,6 +86,6 @@ class AdminSection implements IIconSection {
* {@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 2cc216c..6a83d9e 100644
--- a/templates/navigate.php
+++ b/templates/navigate.php
@@ -31,8 +31,8 @@ declare(strict_types=1);
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 f821fa8..2bab35d 100644
--- a/templates/settings.admin.php
+++ b/templates/settings.admin.php
@@ -32,11 +32,11 @@ use OCA\FullTextSearch\AppInfo\Application;
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');
?>