From 222baf6deb6df7cbd6907472b80e11d7a86fd677 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Mon, 13 Jan 2025 15:22:40 -0800 Subject: [PATCH] feat: Add team resource providers capability Signed-off-by: Christopher Ng --- lib/AppInfo/Capabilities.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/AppInfo/Capabilities.php b/lib/AppInfo/Capabilities.php index 4537c597a..907033b88 100644 --- a/lib/AppInfo/Capabilities.php +++ b/lib/AppInfo/Capabilities.php @@ -9,6 +9,8 @@ namespace OCA\Circles\AppInfo; +use OC\AppFramework\Bootstrap\Coordinator; +use OC\AppFramework\Bootstrap\ServiceRegistration; use OCA\Circles\Model\Circle; use OCA\Circles\Model\Member; use OCA\Circles\Service\ConfigService; @@ -16,6 +18,8 @@ use OCP\App\IAppManager; use OCP\Capabilities\ICapability; use OCP\IL10N; +use OCP\Teams\ITeamResourceProvider; +use Psr\Container\ContainerInterface; class Capabilities implements ICapability { public function __construct( @@ -23,6 +27,8 @@ public function __construct( private IAppManager $appManager, private InterfaceService $interfaceService, private ConfigService $configService, + private Coordinator $coordinator, + private ContainerInterface $container, ) { } @@ -33,7 +39,8 @@ public function getCapabilities(bool $complete = false): array { 'status' => $this->getCapabilitiesStatus($complete), 'settings' => $this->configService->getSettings(), 'circle' => $this->getCapabilitiesCircle(), - 'member' => $this->getCapabilitiesMember() + 'member' => $this->getCapabilitiesMember(), + 'teamResourceProviders' => $this->getCapabilitiesTeamResourceProviders(), ], ]; } @@ -143,4 +150,23 @@ private function getCapabilitiesMemberConstants(): array { ] ]; } + + /** + * @return string[] + */ + private function getCapabilitiesTeamResourceProviders() { + $providers = $this->coordinator->getRegistrationContext()?->getTeamResourceProviders(); + if ($providers === null) { + return []; + } + $providerIds = array_map( + function (ServiceRegistration $registration) { + /** @var ITeamResourceProvider $provider */ + $provider = $this->container->get($registration->getService()); + return $provider->getId(); + }, + $providers, + ); + return $providerIds; + } }