summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/appinfo/application.php5
-rw-r--r--apps/files_sharing/appinfo/application.php6
-rw-r--r--apps/files_trashbin/appinfo/application.php5
-rw-r--r--apps/files_versions/appinfo/application.php5
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php14
-rw-r--r--lib/private/capabilitiesmanager.php3
-rw-r--r--lib/private/server.php8
-rw-r--r--lib/public/appframework/iappcontainer.php7
-rw-r--r--lib/public/capabilities/imanager.php44
-rw-r--r--lib/public/iservercontainer.php7
-rw-r--r--tests/lib/capabilitiesmanager.php31
-rw-r--r--tests/lib/server.php2
12 files changed, 44 insertions, 93 deletions
diff --git a/apps/files/appinfo/application.php b/apps/files/appinfo/application.php
index f121eb7a401..6ba77e09556 100644
--- a/apps/files/appinfo/application.php
+++ b/apps/files/appinfo/application.php
@@ -26,7 +26,6 @@ use OCA\Files\Controller\ApiController;
use OCP\AppFramework\App;
use \OCA\Files\Service\TagService;
use \OCP\IContainer;
-use OCA\Files\Capabilities;
class Application extends App {
public function __construct(array $urlParams=array()) {
@@ -71,8 +70,6 @@ class Application extends App {
/*
* Register capabilities
*/
- $server->getCapabilitiesManager()->registerCapability(function() {
- return new Capabilities();
- });
+ $container->registerCapability('OCA\Files\Capabilities');
}
}
diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php
index 6ddd25acb52..2fe9019d54e 100644
--- a/apps/files_sharing/appinfo/application.php
+++ b/apps/files_sharing/appinfo/application.php
@@ -128,11 +128,7 @@ class Application extends App {
/*
* Register capabilities
*/
- $server->getCapabilitiesManager()->registerCapability(function() use ($server) {
- return new Capabilities(
- $server->getConfig()
- );
- });
+ $container->registerCapability('OCA\Files_Sharing\Capabilities');
}
public function registerMountProviders() {
diff --git a/apps/files_trashbin/appinfo/application.php b/apps/files_trashbin/appinfo/application.php
index 851de142e5c..8d76d40f639 100644
--- a/apps/files_trashbin/appinfo/application.php
+++ b/apps/files_trashbin/appinfo/application.php
@@ -22,7 +22,6 @@
namespace OCA\Files_Trashbin\AppInfo;
use OCP\AppFramework\App;
-use OCA\Files_Trashbin\Capabilities;
class Application extends App {
public function __construct(array $urlParams = array()) {
@@ -33,8 +32,6 @@ class Application extends App {
/*
* Register capabilities
*/
- $server->getCapabilitiesManager()->registerCapability(function() {
- return new Capabilities();
- });
+ $container->registerCapability('OCA\Files_Trashbin\Capabilities');
}
}
diff --git a/apps/files_versions/appinfo/application.php b/apps/files_versions/appinfo/application.php
index 69485bc1f22..bab36b48510 100644
--- a/apps/files_versions/appinfo/application.php
+++ b/apps/files_versions/appinfo/application.php
@@ -22,7 +22,6 @@
namespace OCA\Files_Versions\AppInfo;
use OCP\AppFramework\App;
-use OCA\Files_Versions\Capabilities;
class Application extends App {
public function __construct(array $urlParams = array()) {
@@ -33,8 +32,6 @@ class Application extends App {
/*
* Register capabilities
*/
- $server->getCapabilitiesManager()->registerCapability(function() {
- return new Capabilities();
- });
+ $container->registerCapability('OCA\Files_Versions\Capabilities');
}
}
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
index 927b6d43302..c66b792064d 100644
--- a/lib/private/appframework/dependencyinjection/dicontainer.php
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -96,6 +96,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer()->getMemCacheFactory();
});
+ $this->registerService('OC\\CapabilitiesManager', function($c) {
+ return $this->getServer()->getCapabilitiesManager();
+ });
+
$this->registerService('OCP\\IConfig', function($c) {
return $this->getServer()->getConfig();
});
@@ -390,5 +394,15 @@ class DIContainer extends SimpleContainer implements IAppContainer {
\OCP\Util::writeLog($this->getAppName(), $message, $level);
}
+ /**
+ * Register a capability
+ *
+ * @param string $serviceName e.g. 'OCA\Files\Capabilities'
+ */
+ public function registerCapability($serviceName) {
+ $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) {
+ return $this->query($serviceName);
+ });
+ }
}
diff --git a/lib/private/capabilitiesmanager.php b/lib/private/capabilitiesmanager.php
index ebbd9664897..74154f2c631 100644
--- a/lib/private/capabilitiesmanager.php
+++ b/lib/private/capabilitiesmanager.php
@@ -21,10 +21,9 @@
namespace OC;
-use OCP\Capabilities\IManager;
use OCP\Capabilities\ICapability;
-class CapabilitiesManager implements IManager {
+class CapabilitiesManager {
/**
* @var \Closure[]
diff --git a/lib/private/server.php b/lib/private/server.php
index 5bf3121ec0f..9503cf16ff7 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -452,12 +452,11 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('CapabilitiesManager', function (Server $c) {
$manager = new \OC\CapabilitiesManager();
$manager->registerCapability(function() use ($c) {
- return new \OC\OCS\CoreCapabilities(
- $c->getConfig()
- );
+ return new \OC\OCS\CoreCapabilities($c->getConfig());
});
return $manager;
});
+
}
/**
@@ -958,8 +957,7 @@ class Server extends SimpleContainer implements IServerContainer {
/**
* Get the manager of all the capabilities
*
- * @return \OCP\Capabilities\IManager
- * @since 8.2.0
+ * @return \OC\CapabilitiesManager
*/
public function getCapabilitiesManager() {
return $this->query('CapabilitiesManager');
diff --git a/lib/public/appframework/iappcontainer.php b/lib/public/appframework/iappcontainer.php
index 64b1082aa97..7338dbd858d 100644
--- a/lib/public/appframework/iappcontainer.php
+++ b/lib/public/appframework/iappcontainer.php
@@ -86,4 +86,11 @@ interface IAppContainer extends IContainer {
*/
function log($message, $level);
+ /**
+ * Register a capability
+ *
+ * @param string $serviceName e.g. 'OCA\Files\Capabilities'
+ * @since 8.2.0
+ */
+ public function registerCapability($serviceName);
}
diff --git a/lib/public/capabilities/imanager.php b/lib/public/capabilities/imanager.php
deleted file mode 100644
index df563bd2b25..00000000000
--- a/lib/public/capabilities/imanager.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?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 6cb8d668658..ab1729da255 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -439,11 +439,4 @@ interface IServerContainer {
*/
public function getMimeTypeDetector();
- /**
- * Get the manager of all the capabilities
- *
- * @return \OCP\Capabilities\IManager
- * @since 8.2.0
- */
- public function getCapabilitiesManager();
}
diff --git a/tests/lib/capabilitiesmanager.php b/tests/lib/capabilitiesmanager.php
index 738715344e0..b5dac80ee51 100644
--- a/tests/lib/capabilitiesmanager.php
+++ b/tests/lib/capabilitiesmanager.php
@@ -70,18 +70,14 @@ class CapabilitiesManagerTest extends TestCase {
public function testMergedCapabilities() {
$manager = new \OC\CapabilitiesManager();
- $simple1 = new SimpleCapability();
- $simple2 = new SimpleCapability2();
- $simple3 = new SimpleCapability3();
-
- $manager->registerCapability(function() use ($simple1) {
- return $simple1;
+ $manager->registerCapability(function() {
+ return new SimpleCapability();
});
- $manager->registerCapability(function() use ($simple2) {
- return $simple2;
+ $manager->registerCapability(function() {
+ return new SimpleCapability2();
});
- $manager->registerCapability(function() use ($simple3) {
- return $simple3;
+ $manager->registerCapability(function() {
+ return new SimpleCapability3();
});
$res = $manager->getCapabilities();
@@ -146,6 +142,14 @@ class SimpleCapability3 implements \OCP\Capabilities\ICapability {
}
}
+class NoCapability {
+ public function getCapabilities() {
+ return [
+ 'baz' => 'z'
+ ];
+ }
+}
+
class DeepCapability implements \OCP\Capabilities\ICapability {
public function getCapabilities() {
return [
@@ -158,10 +162,3 @@ class DeepCapability implements \OCP\Capabilities\ICapability {
}
}
-class NoCapability {
- public function getCapabilities() {
- return [
- 'baz' => 'z'
- ];
- }
-}
diff --git a/tests/lib/server.php b/tests/lib/server.php
index 1eb91173deb..9c5c83ceb5c 100644
--- a/tests/lib/server.php
+++ b/tests/lib/server.php
@@ -51,7 +51,7 @@ class Server extends \Test\TestCase {
['AvatarManager', '\OC\AvatarManager'],
['AvatarManager', '\OCP\IAvatarManager'],
- ['CapabilitiesManager', '\OCP\Capabilities\IManager'],
+ ['CapabilitiesManager', '\OC\CapabilitiesManager'],
['ContactsManager', '\OC\ContactsManager'],
['ContactsManager', '\OCP\Contacts\IManager'],
['Crypto', '\OC\Security\Crypto'],