diff options
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/appinfo/application.php | 9 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/routes.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/lib/capabilities.php | 32 | ||||
-rw-r--r-- | apps/files_sharing/tests/capabilities.php | 7 |
4 files changed, 20 insertions, 33 deletions
diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php index b9c2844d78c..2fe9019d54e 100644 --- a/apps/files_sharing/appinfo/application.php +++ b/apps/files_sharing/appinfo/application.php @@ -2,6 +2,7 @@ /** * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> + * @author Roeland Jago Douma <roeland@famdouma.nl> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 @@ -20,7 +21,7 @@ * */ -namespace OCA\Files_Sharing\Appinfo; +namespace OCA\Files_Sharing\AppInfo; use OCA\Files_Sharing\Helper; use OCA\Files_Sharing\MountProvider; @@ -31,6 +32,7 @@ use OCA\Files_Sharing\Controllers\ExternalSharesController; use OCA\Files_Sharing\Controllers\ShareController; use OCA\Files_Sharing\Middleware\SharingCheckMiddleware; use \OCP\IContainer; +use OCA\Files_Sharing\Capabilities; class Application extends App { public function __construct(array $urlParams = array()) { @@ -122,6 +124,11 @@ class Application extends App { $server->getConfig() ); }); + + /* + * Register capabilities + */ + $container->registerCapability('OCA\Files_Sharing\Capabilities'); } public function registerMountProviders() { diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index 21d21a83441..1e99267a43a 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -97,8 +97,3 @@ API::register('delete', array('\OCA\Files_Sharing\API\Remote', 'declineShare'), 'files_sharing'); -// Register with the capabilities API -API::register('get', - '/cloud/capabilities', - array('OCA\Files_Sharing\Capabilities', 'getCapabilities'), - 'files_sharing', API::USER_AUTH); diff --git a/apps/files_sharing/lib/capabilities.php b/apps/files_sharing/lib/capabilities.php index ac6454c3433..ef69a40078b 100644 --- a/apps/files_sharing/lib/capabilities.php +++ b/apps/files_sharing/lib/capabilities.php @@ -20,6 +20,7 @@ */ namespace OCA\Files_Sharing; +use OCP\Capabilities\ICapability; use \OCP\IConfig; /** @@ -27,32 +28,21 @@ use \OCP\IConfig; * * @package OCA\Files_Sharing */ -class Capabilities { +class Capabilities implements ICapability { /** @var IConfig */ private $config; - /** - * @param IConfig $config - */ public function __construct(IConfig $config) { $this->config = $config; } /** - * @return \OC_OCS_Result - */ - public static function getCapabilities() { - $config = \OC::$server->getConfig(); - $cap = new Capabilities($config); - return $cap->getCaps(); - } - - - /** - * @return \OC_OCS_Result + * Return this classes capabilities + * + * @return array */ - public function getCaps() { + public function getCapabilities() { $res = []; $public = []; @@ -76,12 +66,8 @@ class Capabilities { $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes'; - - return new \OC_OCS_Result([ - 'capabilities' => [ - 'files_sharing' => $res - ], - ]); + return [ + 'files_sharing' => $res, + ]; } - } diff --git a/apps/files_sharing/tests/capabilities.php b/apps/files_sharing/tests/capabilities.php index a7c487bf589..b0f6390b013 100644 --- a/apps/files_sharing/tests/capabilities.php +++ b/apps/files_sharing/tests/capabilities.php @@ -36,9 +36,8 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase { * @return string[] */ private function getFilesSharingPart(array $data) { - $this->assertArrayHasKey('capabilities', $data); - $this->assertArrayHasKey('files_sharing', $data['capabilities']); - return $data['capabilities']['files_sharing']; + $this->assertArrayHasKey('files_sharing', $data); + return $data['files_sharing']; } /** @@ -53,7 +52,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase { $stub = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock(); $stub->method('getAppValue')->will($this->returnValueMap($map)); $cap = new Capabilities($stub); - $result = $this->getFilesSharingPart($cap->getCaps()->getData()); + $result = $this->getFilesSharingPart($cap->getCapabilities()); return $result; } |