aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework/Bootstrap/RegistrationContext.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/AppFramework/Bootstrap/RegistrationContext.php')
-rw-r--r--lib/private/AppFramework/Bootstrap/RegistrationContext.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
index 6a9073b576b..401a967c988 100644
--- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php
+++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
@@ -30,6 +30,8 @@ declare(strict_types=1);
namespace OC\AppFramework\Bootstrap;
use Closure;
+use OCP\Talk\ITalkBackend;
+use RuntimeException;
use function array_shift;
use OC\Support\CrashReport\Registry;
use OCP\AppFramework\App;
@@ -65,6 +67,9 @@ class RegistrationContext {
/** @var ServiceRegistration<ILinkAction>[] */
private $profileLinkActions = [];
+ /** @var null|ServiceRegistration<ITalkBackend> */
+ private $talkBackendRegistration = null;
+
/** @var ServiceFactoryRegistration[] */
private $services = [];
@@ -259,6 +264,13 @@ class RegistrationContext {
$actionClass
);
}
+
+ public function registerTalkBackend(string $backend): void {
+ $this->context->registerTalkBackend(
+ $this->appId,
+ $backend
+ );
+ }
};
}
@@ -350,6 +362,21 @@ class RegistrationContext {
}
/**
+ * @psalm-param class-string<ITalkBackend> $backend
+ */
+ public function registerTalkBackend(string $appId, string $backend) {
+ // Some safeguards for invalid registrations
+ if ($appId !== 'spreed') {
+ throw new RuntimeException("Only the Talk app is allowed to register a Talk backend");
+ }
+ if ($this->talkBackendRegistration !== null) {
+ throw new RuntimeException("There can only be one Talk backend");
+ }
+
+ $this->talkBackendRegistration = new ServiceRegistration($appId, $backend);
+ }
+
+ /**
* @param App[] $apps
*/
public function delegateCapabilityRegistrations(array $apps): void {
@@ -600,4 +627,12 @@ class RegistrationContext {
public function getProfileLinkActions(): array {
return $this->profileLinkActions;
}
+
+ /**
+ * @return ServiceRegistration|null
+ * @psalm-return ServiceRegistration<ITalkBackend>|null
+ */
+ public function getTalkBackendRegistration(): ?ServiceRegistration {
+ return $this->talkBackendRegistration;
+ }
}