diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-03-21 20:03:56 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-08-10 10:45:08 +0200 |
commit | 7e6a2b71fd80fedabc64d10bee5ba0edc0b19cf0 (patch) | |
tree | 885ca90351d6b7fd94bf7e843f3cb15d62378c49 /lib/public | |
parent | 214729a5524e2c406415985717c174bedc810954 (diff) | |
download | nextcloud-server-7e6a2b71fd80fedabc64d10bee5ba0edc0b19cf0.tar.gz nextcloud-server-7e6a2b71fd80fedabc64d10bee5ba0edc0b19cf0.zip |
Added Capabilities Manager
* This should allow the capabilities to be intergrated into the
appframework
* Unit tests
* Throw exception if closure does not return ICapability instance
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/capabilities/icapability.php | 46 | ||||
-rw-r--r-- | lib/public/capabilities/imanager.php | 44 | ||||
-rw-r--r-- | lib/public/iservercontainer.php | 8 |
3 files changed, 98 insertions, 0 deletions
diff --git a/lib/public/capabilities/icapability.php b/lib/public/capabilities/icapability.php new file mode 100644 index 00000000000..71a56128d26 --- /dev/null +++ b/lib/public/capabilities/icapability.php @@ -0,0 +1,46 @@ +<?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 OCP\Capabilities; + +/** + * Minimal interface that has to be implemented for a class to be considered + * a capability. + * + * In an application use: + * $this->getContainer()->registerCapability('OCA\MY_APP\Capabilities'); + * To register capabilities. + * + * The class 'OCA\MY_APP\Capabilities' must then implement ICapability + * + * @since 8.2.0 + */ +interface ICapability { + + /** + * Function an app uses to return the capabilities + * + * @return array Array containing the apps capabilities + * @since 8.2.0 + */ + public function getCapabilities(); +} + diff --git a/lib/public/capabilities/imanager.php b/lib/public/capabilities/imanager.php new file mode 100644 index 00000000000..df563bd2b25 --- /dev/null +++ b/lib/public/capabilities/imanager.php @@ -0,0 +1,44 @@ +<?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 OCP\Capabilities; + + +interface IManager { + + /** + * Get an array of al the capabilities that are registered at this manager + * + * @return array All the capabilities registered in this manager + * @since 8.2.0 + */ + public function getCapabilities(); + + /** + * In order to improve lazy loading a closure can be registered which will be called in case + * activity consumers are actually requested + * + * $callable has to return an instance of OCP\Capabilities\ICapability + * + * @param \Closure $callable + * @since 8.2.0 + */ + public function registerCapability(\Closure $callable); +} diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index f3165db33da..6cb8d668658 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -438,4 +438,12 @@ interface IServerContainer { * @since 8.2.0 */ public function getMimeTypeDetector(); + + /** + * Get the manager of all the capabilities + * + * @return \OCP\Capabilities\IManager + * @since 8.2.0 + */ + public function getCapabilitiesManager(); } |