2019-09-29 14:57:00 -04:00
|
|
|
<?php
|
2019-12-19 07:16:31 -05:00
|
|
|
|
2019-09-29 14:57:00 -04:00
|
|
|
declare(strict_types=1);
|
2019-12-19 07:16:31 -05:00
|
|
|
|
2019-09-29 14:57:00 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-09-29 14:57:00 -04:00
|
|
|
*/
|
|
|
|
|
namespace OC\Collaboration\Resources;
|
|
|
|
|
|
|
|
|
|
use OCP\AppFramework\QueryException;
|
|
|
|
|
use OCP\Collaboration\Resources\IProvider;
|
|
|
|
|
use OCP\Collaboration\Resources\IProviderManager;
|
|
|
|
|
use OCP\IServerContainer;
|
2021-04-16 08:26:43 -04:00
|
|
|
use Psr\Log\LoggerInterface;
|
2019-09-29 14:57:00 -04:00
|
|
|
|
|
|
|
|
class ProviderManager implements IProviderManager {
|
|
|
|
|
/** @var string[] */
|
2023-07-03 03:37:33 -04:00
|
|
|
protected array $providers = [];
|
2019-09-29 14:57:00 -04:00
|
|
|
|
|
|
|
|
/** @var IProvider[] */
|
2023-07-03 03:37:33 -04:00
|
|
|
protected array $providerInstances = [];
|
2019-09-29 14:57:00 -04:00
|
|
|
|
2023-07-03 03:37:33 -04:00
|
|
|
public function __construct(
|
|
|
|
|
protected IServerContainer $serverContainer,
|
|
|
|
|
protected LoggerInterface $logger,
|
|
|
|
|
) {
|
2019-09-29 14:57:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getResourceProviders(): array {
|
|
|
|
|
if ($this->providers !== []) {
|
|
|
|
|
foreach ($this->providers as $provider) {
|
|
|
|
|
try {
|
|
|
|
|
$this->providerInstances[] = $this->serverContainer->query($provider);
|
|
|
|
|
} catch (QueryException $e) {
|
2021-04-16 08:26:43 -04:00
|
|
|
$this->logger->error("Could not query resource provider $provider: " . $e->getMessage(), [
|
|
|
|
|
'exception' => $e,
|
2019-09-29 14:57:00 -04:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->providers = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->providerInstances;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function registerResourceProvider(string $provider): void {
|
|
|
|
|
$this->providers[] = $provider;
|
|
|
|
|
}
|
|
|
|
|
}
|