From d85e3e3a6d775261cd4a504e07b111224cda8fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 24 Jan 2019 11:43:18 +0100 Subject: [PATCH] Allow apps to register resource providers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files/lib/AppInfo/Application.php | 9 +++++++++ lib/private/Collaboration/Resources/Manager.php | 15 +++++++++++---- lib/public/Collaboration/Resources/IManager.php | 4 ++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php index d4dac5befa..8f8c1e299b 100644 --- a/apps/files/lib/AppInfo/Application.php +++ b/apps/files/lib/AppInfo/Application.php @@ -27,9 +27,11 @@ namespace OCA\Files\AppInfo; use OCA\Files\Activity\Helper; +use OCA\Files\Collaboration\Resources\ResourceProvider; use OCA\Files\Controller\ApiController; use OCP\AppFramework\App; use \OCA\Files\Service\TagService; +use OCP\Collaboration\Resources\IManager; use \OCP\IContainer; use OCA\Files\Controller\ViewController; use OCA\Files\Capabilities; @@ -99,5 +101,12 @@ class Application extends App { * Register capabilities */ $container->registerCapability(Capabilities::class); + + /** + * Register Collaboration ResourceProvider + */ + /** @var IManager $resourceManager */ + $resourceManager = $container->query(IManager::class); + $resourceManager->registerResourceProvider($container->query(ResourceProvider::class)); } } diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index cc09089c71..071fa3c943 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace OC\Collaboration\Resources; -use OCA\Files\Collaboration\Resources\ResourceProvider; use OCP\Collaboration\Resources\CollectionException; use OCP\Collaboration\Resources\ICollection; use OCP\Collaboration\Resources\IManager; @@ -39,6 +38,9 @@ class Manager implements IManager { /** @var IDBConnection */ protected $connection; + /** @var IProvider[] */ + protected $providers = []; + public function __construct(IDBConnection $connection) { $this->connection = $connection; } @@ -96,9 +98,7 @@ class Manager implements IManager { * @since 15.0.0 */ public function getProviders(): array { - return [ - \OC::$server->query(ResourceProvider::class) // FIXME - ]; + return $this->providers; } /** @@ -155,4 +155,11 @@ class Manager implements IManager { return false; } + + /** + * @param IProvider $provider + */ + public function registerResourceProvider(IProvider $provider): void { + $this->providers[] = $provider; + } } diff --git a/lib/public/Collaboration/Resources/IManager.php b/lib/public/Collaboration/Resources/IManager.php index dd1c970af7..eab101ff8e 100644 --- a/lib/public/Collaboration/Resources/IManager.php +++ b/lib/public/Collaboration/Resources/IManager.php @@ -50,4 +50,8 @@ interface IManager extends IProvider { */ public function getResource(string $type, string $id): IResource; + /** + * @param IProvider $provider + */ + public function registerResourceProvider(IProvider $provider): void; }