check if cloud federation api is ready

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
Bjoern Schiessle 2018-05-02 17:15:07 +02:00
parent 4c8f3d6d77
commit 6208f250e8
No known key found for this signature in database
GPG Key ID: 2378A753E2BF04F6
3 changed files with 25 additions and 2 deletions

View File

@ -22,6 +22,7 @@
namespace OC\Federation;
use OCP\App\IAppManager;
use OCP\Federation\Exceptions\ProviderAlreadyExistsException;
use OCP\Federation\Exceptions\ProviderDoesNotExistsException;
use OCP\Federation\ICloudFederationNotification;
@ -41,8 +42,12 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager
/** @var array list of available cloud federation providers */
private $cloudFederationProvider;
public function __construct() {
/** @var IAppManager */
private $appManager;
public function __construct(IAppManager $appManager) {
$this->cloudFederationProvider= [];
$this->appManager = $appManager;
}
@ -105,4 +110,13 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager
// TODO: Implement sendNotification() method.
}
/**
* check if the new cloud federation API is ready to be used
*
* @return bool
*/
public function isReady() {
return $this->appManager->isEnabledForUser('cloud_federation_api', false);
}
}

View File

@ -1117,7 +1117,7 @@ class Server extends ServerContainer implements IServerContainer {
});
$this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
return new CloudFederationProviderManager();
return new CloudFederationProviderManager($c->getAppManager());
});
$this->registerService(ICloudFederationFactory::class, function (Server $c) {

View File

@ -93,5 +93,14 @@ interface ICloudFederationProviderManager {
*/
public function sendNotification(ICloudFederationNotification $notification);
/**
* check if the new cloud federation API is ready to be used
*
* @return bool
*
* @since 14.0.0
*/
public function isReady();
}