diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-11-25 13:56:22 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-11-27 14:36:21 +0100 |
commit | bc36cc808fb9ed9ff22c42246fe68f06cedb902e (patch) | |
tree | dbdc538fae802d97bf04b93c02fde177c466b86b /apps/files | |
parent | c8d3e32190d8672c9fc42cd30a63182623006431 (diff) | |
download | nextcloud-server-bc36cc808fb9ed9ff22c42246fe68f06cedb902e.tar.gz nextcloud-server-bc36cc808fb9ed9ff22c42246fe68f06cedb902e.zip |
Move editor list to capabilities
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/appinfo/routes.php | 5 | ||||
-rw-r--r-- | apps/files/lib/Capabilities.php | 43 | ||||
-rw-r--r-- | apps/files/lib/Controller/DirectEditingController.php | 42 |
3 files changed, 42 insertions, 48 deletions
diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 6f8a6878aac..f900b5ffbd8 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -100,11 +100,6 @@ $application->registerRoutes( ], 'ocs' => [ [ - 'name' => 'DirectEditing#get', - 'url' => '/api/v1/directEditing', - 'verb' => 'GET' - ], - [ 'name' => 'DirectEditing#templates', 'url' => '/api/v1/directEditing/templates/{editorId}/{creatorId}', 'verb' => 'GET' diff --git a/apps/files/lib/Capabilities.php b/apps/files/lib/Capabilities.php index 2b6bf57b90d..c37e32b6b59 100644 --- a/apps/files/lib/Capabilities.php +++ b/apps/files/lib/Capabilities.php @@ -25,7 +25,11 @@ namespace OCA\Files; +use OC\DirectEditing\Manager; use OCP\Capabilities\ICapability; +use OCP\DirectEditing\ACreateEmpty; +use OCP\DirectEditing\ACreateFromTemplate; +use OCP\DirectEditing\IEditor; use OCP\IConfig; /** @@ -42,8 +46,9 @@ class Capabilities implements ICapability { * * @param IConfig $config */ - public function __construct(IConfig $config) { + public function __construct(IConfig $config, Manager $manager) { $this->config = $config; + $this->directEditingManager = $manager; } /** @@ -56,7 +61,43 @@ class Capabilities implements ICapability { 'files' => [ 'bigfilechunking' => true, 'blacklisted_files' => $this->config->getSystemValue('blacklisted_files', ['.htaccess']), + 'directEditing' => $this->getDirectEditingCapabilitites() ], ]; } + + private function getDirectEditingCapabilitites() { + $capabilities = [ + 'editors' => [], + 'creators' => [] + ]; + + /** + * @var string $id + * @var IEditor $editor + */ + foreach ($this->directEditingManager->getEditors() as $id => $editor) { + $capabilities['editors'][$id] = [ + 'name' => $editor->getName(), + 'mimetypes' => $editor->getMimetypes(), + 'optionalMimetypes' => $editor->getMimetypesOptional(), + 'secure' => $editor->isSecure(), + ]; + /** @var ACreateEmpty|ACreateFromTemplate $creator */ + foreach ($editor->getCreators() as $creator) { + $id = $creator->getId(); + $capabilities['creators'][$id] = [ + 'id' => $id, + 'name' => $creator->getName(), + 'extension' => $creator->getExtension(), + 'templates' => false + ]; + if ($creator instanceof ACreateFromTemplate) { + $capabilities['creators'][$id]['templates'] = true; + } + + } + } + return $capabilities; + } } diff --git a/apps/files/lib/Controller/DirectEditingController.php b/apps/files/lib/Controller/DirectEditingController.php index cf948d20f76..e8791316442 100644 --- a/apps/files/lib/Controller/DirectEditingController.php +++ b/apps/files/lib/Controller/DirectEditingController.php @@ -64,48 +64,6 @@ class DirectEditingController extends OCSController { /** * @NoAdminRequired - * - * @return DataResponse - */ - public function get(): DataResponse { - $this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager)); - - $capabilities = [ - 'editors' => [], - 'creators' => [] - ]; - - /** - * @var string $id - * @var IEditor $editor - */ - foreach ($this->directEditingManager->getEditors() as $id => $editor) { - $capabilities['editors'][$id] = [ - 'name' => $editor->getName(), - 'mimetypes' => $editor->getMimetypes(), - 'optionalMimetypes' => $editor->getMimetypesOptional(), - 'secure' => $editor->isSecure(), - ]; - /** @var ACreateEmpty|ACreateFromTemplate $creator */ - foreach ($editor->getCreators() as $creator) { - $id = $creator->getId(); - $capabilities['creators'][$id] = [ - 'id' => $id, - 'name' => $creator->getName(), - 'extension' => $creator->getExtension(), - 'templates' => false - ]; - if ($creator instanceof ACreateFromTemplate) { - $capabilities['creators'][$id]['templates'] = true; - } - - } - } - return new DataResponse($capabilities); - } - - /** - * @NoAdminRequired */ public function create(string $path, string $editorId, string $creatorId, string $templateId = null): DataResponse { $this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager)); |