Move core capabilities to new class

This commit is contained in:
Roeland Jago Douma 2015-07-21 21:44:59 +02:00
parent e84cffc063
commit c80c9819dc
3 changed files with 65 additions and 11 deletions

View File

@ -37,14 +37,7 @@ class OC_OCS_Cloud {
'edition' => OC_Util::getEditionString(),
);
$result['capabilities'] = array(
'core' => array(
'pollinterval' => OC_Config::getValue('pollinterval', 60),
),
);
$result['capabilities'] = array_merge_recursive($result['capabilities'], \OC::$server->getCapabilitiesManager()->getCapabilities());
$result['capabilities'] = \OC::$server->getCapabilitiesManager()->getCapabilities();
return new OC_OCS_Result($result);
}

View File

@ -0,0 +1,56 @@
<?php
/**
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\OCS;
use OCP\Capabilities\ICapability;
use OCP\IConfig;
/**
* Class Capabilities
*
* @package OC\OCS
*/
class CoreCapabilities implements ICapability {
/** @var IConfig */
private $config;
/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
* Return this classes capabilities
*
* @return array
*/
public function getCapabilities() {
return [
'core' => [
'pollinterval' => $this->config->getSystemValue('pollinterval', 60)
]
];
}
}

View File

@ -59,7 +59,6 @@ use OC\Security\SecureRandom;
use OC\Security\TrustedDomainHelper;
use OC\Tagging\TagMapper;
use OCP\IServerContainer;
use OC\CapabilitiesManager;
/**
* Class Server
@ -450,8 +449,14 @@ class Server extends SimpleContainer implements IServerContainer {
$c->getURLGenerator(),
\OC::$configDir);
});
$this->registerService('CapabilitiesManager', function () {
return new CapabilitiesManager();
$this->registerService('CapabilitiesManager', function (Server $c) {
$manager = new \OC\CapabilitiesManager();
$manager->registerCapability(function() use ($c) {
return new \OC\OCS\CoreCapabilities(
$c->getConfig()
);
});
return $manager;
});
}