From b246d51cbc5105b9c4e85867297ee19f6d2459e5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 12 Oct 2023 12:25:16 +0200 Subject: fix(OCM): Make the OCM provider stateful so apps can add resources Signed-off-by: Joas Schilling --- apps/cloud_federation_api/appinfo/info.xml | 4 ++-- apps/cloud_federation_api/lib/Capabilities.php | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'apps') diff --git a/apps/cloud_federation_api/appinfo/info.xml b/apps/cloud_federation_api/appinfo/info.xml index f9ca8185dcf..8de2444ff2a 100644 --- a/apps/cloud_federation_api/appinfo/info.xml +++ b/apps/cloud_federation_api/appinfo/info.xml @@ -12,8 +12,8 @@ - files - https://github.com/nextcloud/cloud_federation/issues + integration + https://github.com/nextcloud/server/issues diff --git a/apps/cloud_federation_api/lib/Capabilities.php b/apps/cloud_federation_api/lib/Capabilities.php index 1682effb145..cd44d13117a 100644 --- a/apps/cloud_federation_api/lib/Capabilities.php +++ b/apps/cloud_federation_api/lib/Capabilities.php @@ -28,11 +28,11 @@ declare(strict_types=1); namespace OCA\CloudFederationAPI; -use OC\OCM\Model\OCMProvider; use OC\OCM\Model\OCMResource; use OCP\Capabilities\ICapability; use OCP\IURLGenerator; use OCP\OCM\Exceptions\OCMArgumentException; +use OCP\OCM\IOCMProvider; class Capabilities implements ICapability { @@ -40,6 +40,7 @@ class Capabilities implements ICapability { public function __construct( private IURLGenerator $urlGenerator, + private IOCMProvider $provider, ) { } @@ -63,24 +64,23 @@ class Capabilities implements ICapability { public function getCapabilities() { $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); - $provider = new OCMProvider(); - $provider->setEnabled(true); - $provider->setApiVersion(self::API_VERSION); + $this->provider->setEnabled(true); + $this->provider->setApiVersion(self::API_VERSION); $pos = strrpos($url, '/'); if (false === $pos) { throw new OCMArgumentException('generated route should contains a slash character'); } - $provider->setEndPoint(substr($url, 0, $pos)); + $this->provider->setEndPoint(substr($url, 0, $pos)); $resource = new OCMResource(); $resource->setName('file') ->setShareTypes(['user', 'group']) ->setProtocols(['webdav' => '/public.php/webdav/']); - $provider->setResourceTypes([$resource]); + $this->provider->setResourceTypes([$resource]); - return ['ocm' => $provider->jsonSerialize()]; + return ['ocm' => $this->provider->jsonSerialize()]; } } -- cgit v1.2.3