From f8394e3551de6993f163fea12019cbbc32fc5167 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 29 Nov 2019 11:25:25 +0100 Subject: [PATCH] flow file entity to provide the internal URL Signed-off-by: Arthur Schiwon --- apps/workflowengine/lib/Entity/File.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/workflowengine/lib/Entity/File.php b/apps/workflowengine/lib/Entity/File.php index 9c44a383d6..2bd10ea27a 100644 --- a/apps/workflowengine/lib/Entity/File.php +++ b/apps/workflowengine/lib/Entity/File.php @@ -26,6 +26,7 @@ namespace OCA\WorkflowEngine\Entity; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\GenericEvent; +use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; @@ -38,11 +39,12 @@ use OCP\SystemTag\ISystemTag; use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\MapperEvent; use OCP\WorkflowEngine\EntityContext\IDisplayText; +use OCP\WorkflowEngine\EntityContext\IUrl; use OCP\WorkflowEngine\GenericEntityEvent; use OCP\WorkflowEngine\IEntity; use OCP\WorkflowEngine\IRuleMatcher; -class File implements IEntity, IDisplayText { +class File implements IEntity, IDisplayText, IUrl { private const EVENT_NAMESPACE = '\OCP\Files::'; @@ -208,4 +210,14 @@ class File implements IEntity, IDisplayText { return $this->l10n->t('%s assigned %s to %s', $options); } } + + public function getUrl(): string { + try { + return $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $this->getNode()->getId()]); + } catch (InvalidPathException $e) { + return ''; + } catch (NotFoundException $e) { + return ''; + } + } }