]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow OCS routes in Core and Settings
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 9 Aug 2016 08:21:20 +0000 (10:21 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Tue, 9 Aug 2016 18:56:31 +0000 (20:56 +0200)
core/Controller/OCSController.php [new file with mode: 0644]
lib/private/Route/Router.php

diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php
new file mode 100644 (file)
index 0000000..278a161
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace OC\Core\Controller;
+
+use OC\CapabilitiesManager;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\IRequest;
+
+class OCSController extends \OCP\AppFramework\OCSController {
+
+       /** @var CapabilitiesManager */
+       private $capabilitiesManager;
+
+       /**
+        * OCSController constructor.
+        *
+        * @param string $appName
+        * @param IRequest $request
+        * @param CapabilitiesManager $capabilitiesManager
+        */
+       public function __construct($appName,
+                                                               IRequest $request,
+                                                               CapabilitiesManager $capabilitiesManager) {
+               parent::__construct($appName, $request);
+
+               $this->capabilitiesManager = $capabilitiesManager;
+       }
+
+       public function getCapabilities() {
+               $result = [];
+               list($major, $minor, $micro) = \OCP\Util::getVersion();
+               $result['version'] = array(
+                       'major' => $major,
+                       'minor' => $minor,
+                       'micro' => $micro,
+                       'string' => \OC_Util::getVersionString(),
+                       'edition' => \OC_Util::getEditionString(),
+               );
+
+               $result['capabilities'] = $this->capabilitiesManager->getCapabilities();
+
+               return new DataResponse(['data' => $result]);
+       }
+}
\ No newline at end of file
index 9df74184448e19d6ebf43551d91d2d4c50c4fb64..59f403d66e88784c9fb49a7d06c92a315f2b7e49 100644 (file)
@@ -163,6 +163,11 @@ class Router implements IRouter {
                        $this->useCollection('root');
                        require_once __DIR__ . '/../../../settings/routes.php';
                        require_once __DIR__ . '/../../../core/routes.php';
+
+                       // Also add the OCS collection
+                       $collection = $this->getCollection('root.ocs');
+                       $collection->addPrefix('/ocsapp');
+                       $this->root->addCollection($collection);
                }
                if ($this->loaded) {
                        // include ocs routes, must be loaded last for /ocs prefix