aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-07-12 13:04:54 +0200
committerGitHub <noreply@github.com>2017-07-12 13:04:54 +0200
commit86a496d94ae438ae5de033fd6d9c5bee19ed4fcf (patch)
tree6e732e1beb26840b6345c48495c129eab173d8d0 /lib
parent08d3cb9107ef800112cc131dfd41b0dd6c43f1f7 (diff)
parent44d39d87c015e039fc0ed4fd4ad0668899676233 (diff)
downloadnextcloud-server-86a496d94ae438ae5de033fd6d9c5bee19ed4fcf.tar.gz
nextcloud-server-86a496d94ae438ae5de033fd6d9c5bee19ed4fcf.zip
Merge pull request #5567 from nextcloud/public-capabilities
Public capabilities API
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/CapabilitiesManager.php8
-rw-r--r--lib/public/Capabilities/IPublicCapability.php32
4 files changed, 40 insertions, 2 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 5a8a921f219..a803bc377ff 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -66,6 +66,7 @@ return array(
'OCP\\BackgroundJob\\IJob' => $baseDir . '/lib/public/BackgroundJob/IJob.php',
'OCP\\BackgroundJob\\IJobList' => $baseDir . '/lib/public/BackgroundJob/IJobList.php',
'OCP\\Capabilities\\ICapability' => $baseDir . '/lib/public/Capabilities/ICapability.php',
+ 'OCP\\Capabilities\\IPublicCapability' => $baseDir . '/lib/public/Capabilities/IPublicCapability.php',
'OCP\\Command\\IBus' => $baseDir . '/lib/public/Command/IBus.php',
'OCP\\Command\\ICommand' => $baseDir . '/lib/public/Command/ICommand.php',
'OCP\\Comments\\CommentsEntityEvent' => $baseDir . '/lib/public/Comments/CommentsEntityEvent.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index b4aa6cc322b..63d922eb20a 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -96,6 +96,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\BackgroundJob\\IJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/IJob.php',
'OCP\\BackgroundJob\\IJobList' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/IJobList.php',
'OCP\\Capabilities\\ICapability' => __DIR__ . '/../../..' . '/lib/public/Capabilities/ICapability.php',
+ 'OCP\\Capabilities\\IPublicCapability' => __DIR__ . '/../../..' . '/lib/public/Capabilities/IPublicCapability.php',
'OCP\\Command\\IBus' => __DIR__ . '/../../..' . '/lib/public/Command/IBus.php',
'OCP\\Command\\ICommand' => __DIR__ . '/../../..' . '/lib/public/Command/ICommand.php',
'OCP\\Comments\\CommentsEntityEvent' => __DIR__ . '/../../..' . '/lib/public/Comments/CommentsEntityEvent.php',
diff --git a/lib/private/CapabilitiesManager.php b/lib/private/CapabilitiesManager.php
index 159fa97c708..baab63c213d 100644
--- a/lib/private/CapabilitiesManager.php
+++ b/lib/private/CapabilitiesManager.php
@@ -24,6 +24,7 @@ namespace OC;
use OCP\AppFramework\QueryException;
use OCP\Capabilities\ICapability;
+use OCP\Capabilities\IPublicCapability;
use OCP\ILogger;
class CapabilitiesManager {
@@ -41,10 +42,11 @@ class CapabilitiesManager {
/**
* Get an array of al the capabilities that are registered at this manager
*
+ * @param bool $public get public capabilities only
* @throws \InvalidArgumentException
* @return array
*/
- public function getCapabilities() {
+ public function getCapabilities($public = false) {
$capabilities = [];
foreach($this->capabilities as $capability) {
try {
@@ -55,7 +57,9 @@ class CapabilitiesManager {
}
if ($c instanceof ICapability) {
- $capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
+ if(!$public || $c instanceof IPublicCapability) {
+ $capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
+ }
} else {
throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
}
diff --git a/lib/public/Capabilities/IPublicCapability.php b/lib/public/Capabilities/IPublicCapability.php
new file mode 100644
index 00000000000..ded58f1208b
--- /dev/null
+++ b/lib/public/Capabilities/IPublicCapability.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Capabilities;
+
+/**
+ * @inheritdoc
+ *
+ * @since 13.0.0
+ */
+interface IPublicCapability extends ICapability {}
+