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

github.com/nextcloud/documentserver_community.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-03-26 18:18:19 +0300
committerRobin Appelman <robin@icewind.nl>2021-03-26 18:18:23 +0300
commit4956ceda3b1336c0a5ff34571143002bf60b3019 (patch)
tree950bf0e7e504fe03aa751f037117b9dc144c50cd
parenta53cb1ca60797d380c5d00773d300fb05edea0ae (diff)
move to IBootstrap
-rw-r--r--appinfo/app.php5
-rw-r--r--appinfo/info.xml2
-rw-r--r--lib/AppInfo/Application.php54
-rw-r--r--lib/Controller/SessionController.php2
-rw-r--r--lib/IPC/RedisIPCBackend.php2
-rw-r--r--lib/SetupCheck.php2
6 files changed, 36 insertions, 31 deletions
diff --git a/appinfo/app.php b/appinfo/app.php
deleted file mode 100644
index c66cea0..0000000
--- a/appinfo/app.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-
-use OCA\DocumentServer\AppInfo\Application;
-
-(\OC::$server->query(Application::class))->register();
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 7fd550a..adce68a 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -31,7 +31,7 @@ Additionally, the community document server only supports running on x86-64 Linu
<screenshot>https://raw.githubusercontent.com/nextcloud/documentserver_community/master/screenshots/main.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/documentserver_community/master/screenshots/new.png</screenshot>
<dependencies>
- <nextcloud min-version="19" max-version="21"/>
+ <nextcloud min-version="20" max-version="21"/>
</dependencies>
<background-jobs>
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 2a99a5c..03add89 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -31,61 +31,71 @@ use OCA\DocumentServer\OnlyOffice\AutoConfig;
use OCA\DocumentServer\OnlyOffice\URLDecoder;
use OCA\Onlyoffice\AppConfig;
use OCA\Onlyoffice\Crypt;
+use OCP\App\IAppManager;
use OCP\AppFramework\App;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
+use OCP\Files\IRootFolder;
+use OCP\IURLGenerator;
+use OCP\IUserSession;
+use OCP\Share\IManager;
use OCP\Util;
-class Application extends App {
+class Application extends App implements IBootstrap {
public function __construct(array $urlParams = []) {
parent::__construct('documentserver_community', $urlParams);
+ }
- $container = $this->getContainer();
-
- $container->registerService(IIPCFactory::class, function (IAppContainer $c) {
+ public function register(IRegistrationContext $context): void {
+ $context->registerService(IIPCFactory::class, function (IAppContainer $c) {
$factory = new IPCFactory();
- $factory->registerBackend($c->query(DatabaseIPCFactory::class));
- $factory->registerBackend($c->query(MemcacheIPCFactory::class));
- $factory->registerBackend($c->query(RedisIPCFactory::class));
+ $factory->registerBackend($c->get(DatabaseIPCFactory::class));
+ $factory->registerBackend($c->get(MemcacheIPCFactory::class));
+ $factory->registerBackend($c->get(RedisIPCFactory::class));
return $factory;
});
- $container->registerService(URLDecoder::class, function (IAppContainer $container) {
+ $context->registerService(URLDecoder::class, function (IAppContainer $container) {
$server = $container->getServer();
$appConfig = new AppConfig('onlyoffice');
$crypto = new Crypt($appConfig);
return new URLDecoder(
$crypto,
- $server->getUserSession(),
- $server->getShareManager(),
- $server->getRootFolder()
+ $server->get(IUserSession::class),
+ $server->get(IManager::class),
+ $server->get(IRootFolder::class)
);
});
- $container->registerService(AutoConfig::class, function (IAppContainer $container) {
+ $context->registerService(AutoConfig::class, function (IAppContainer $container) {
$server = $container->getServer();
$appConfig = new AppConfig('onlyoffice');
return new AutoConfig(
- $server->getURLGenerator(),
+ $server->get(IURLGenerator::class),
$appConfig
);
});
}
- private function getJSSettingsHelper(): JSSettingsHelper {
- return $this->getContainer()->query(JSSettingsHelper::class);
+ public function boot(IBootContext $context): void {
+ $context->injectFn(function (IAppManager $appManager) {
+ if ($appManager->isEnabledForUser('onlyoffice')) {
+ $this->getAutoConfig()->autoConfigIfNeeded();
+ Util::connectHook('\OCP\Config', 'js', $this->getJSSettingsHelper(), 'extend');
+ }
+ });
}
- private function getAutoConfig(): AutoConfig {
- return $this->getContainer()->query(AutoConfig::class);
+ private function getJSSettingsHelper(): JSSettingsHelper {
+ return $this->getContainer()->get(JSSettingsHelper::class);
}
- public function register() {
- if ($this->getContainer()->getServer()->getAppManager()->isEnabledForUser('onlyoffice')) {
- $this->getAutoConfig()->autoConfigIfNeeded();
- Util::connectHook('\OCP\Config', 'js', $this->getJSSettingsHelper(), 'extend');
- }
+ private function getAutoConfig(): AutoConfig {
+ return $this->getContainer()->get(AutoConfig::class);
}
}
diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php
index 3efc8fb..ac1b081 100644
--- a/lib/Controller/SessionController.php
+++ b/lib/Controller/SessionController.php
@@ -98,7 +98,7 @@ abstract class SessionController extends Controller {
*/
public function xhr(?string $version, string $documentId, string $serverId, string $sessionId) {
$session = $this->sessionFactory->getSession($sessionId, $documentId, $this->getCommandDispatcher(), $this->getInitialResponses());
- list($type, $data) = $session->getResponse();
+ [$type, $data] = $session->getResponse();
return new XHRResponse($type, $data);
}
diff --git a/lib/IPC/RedisIPCBackend.php b/lib/IPC/RedisIPCBackend.php
index 58e6b8c..4eb52b3 100644
--- a/lib/IPC/RedisIPCBackend.php
+++ b/lib/IPC/RedisIPCBackend.php
@@ -48,7 +48,7 @@ class RedisIPCBackend implements IIPCBackend {
return null;
}
- list(, $message) = $response;
+ [, $message] = $response;
if (is_string($message)) {
return $message;
} else {
diff --git a/lib/SetupCheck.php b/lib/SetupCheck.php
index 1727d0f..a5c4ed9 100644
--- a/lib/SetupCheck.php
+++ b/lib/SetupCheck.php
@@ -46,7 +46,7 @@ class SetupCheck {
return "x2t binary missing, please try removing and re-installing the app";
} elseif (PHP_INT_SIZE === 4) {
return "32 bit setups are not supported";
- } elseif (PHP_OS_FAMILY !== "Linux") {
+ } elseif (PHP_OS_FAMILY !== "Linux") {
return "only linux based servers are supported";
}