From ea01c1d623013b166ae5b0f228148838633bc872 Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Wed, 12 Apr 2023 17:29:13 +0000 Subject: [PATCH] Rely on config and DI rather than specific app names --- .../lib/Controller/OcmController.php | 18 ++++++++++-------- .../Controllers/ExternalSharesController.php | 7 ++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/federatedfilesharing/lib/Controller/OcmController.php b/apps/federatedfilesharing/lib/Controller/OcmController.php index 6f0b9c219476..f55b0cef933c 100644 --- a/apps/federatedfilesharing/lib/Controller/OcmController.php +++ b/apps/federatedfilesharing/lib/Controller/OcmController.php @@ -177,10 +177,11 @@ public function createShare( $resourceType, $protocol ) { - // Allow the Federated Groups app to overwrite the behaviour of this endpoint (but only for group shares) - if (\OC::$server->getAppManager()->isEnabledForUser('federatedgroups') && ($shareType === 'group')) { - $controller = \OCA\FederatedGroups\Application::getOcmController($this->request); - return $controller->createShare( + // Allow other apps to overwrite the behaviour of this endpoint + $controllerClass = $this->config->getSystemValue('sharing.ocmController'); + if ($controllerClass !== '') { + $controller = \OC::$server->query($controllerClass); + return $controller->createShare( $shareWith, $name, $description, @@ -301,10 +302,11 @@ public function processNotification( $providerId, $notification ) { - // Allow the Federated Groups app to overwrite the behaviour of this endpoint - if (\OC::$server->getAppManager()->isEnabledForUser('federatedgroups')) { - $controller = \OCA\FederatedGroups\Application::getOcmController($this->request); - return $controller->processNotification( + // Allow other apps to overwrite the behaviour of this endpoint + $controllerClass = $this->config->getSystemValue('sharing.ocmController'); + if ($controllerClass !== '') { + $controller = \OC::$server->query($controllerClass); + return $controller->processNotification( $notificationType, $resourceType, $providerId, diff --git a/apps/files_sharing/lib/Controllers/ExternalSharesController.php b/apps/files_sharing/lib/Controllers/ExternalSharesController.php index 02db6ef4acb4..4ab3bce063f3 100644 --- a/apps/files_sharing/lib/Controllers/ExternalSharesController.php +++ b/apps/files_sharing/lib/Controllers/ExternalSharesController.php @@ -39,7 +39,6 @@ * @package OCA\Files_Sharing\Controllers */ class ExternalSharesController extends Controller { - /** @var \OCA\Files_Sharing\External\Manager */ private $externalManager; /** @var \OCA\Files_Sharing\External\Manager */ @@ -71,8 +70,10 @@ public function __construct( $this->externalManager = $externalManager; $this->clientService = $clientService; $this->dispatcher = $eventDispatcher; - if (\OC::$server->getAppManager()->isEnabledForUser('federatedgroups')) { - $this->groupExternalManager = \OCA\FederatedGroups\Application::getExternalManager(); + // Allow other apps to add an external manager for user-to-group shares + $managerClass = $this->config->getSystemValue('sharing.groupExternalManager'); + if ($managerClass !== '') { + $this->groupExternalManager = \OC::$server->query($managerClass); } }