Skip to content
Snippets Groups Projects
Unverified Commit 5a986f02 authored by blizzz's avatar blizzz Committed by GitHub
Browse files

Merge pull request #18162 from nextcloud/enh/noid/url-fileentity

flow file entity to provide the internal URL
parents eaf89d1c f8394e35
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ namespace OCA\WorkflowEngine\Entity; ...@@ -26,6 +26,7 @@ namespace OCA\WorkflowEngine\Entity;
use OCP\EventDispatcher\Event; use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\GenericEvent; use OCP\EventDispatcher\GenericEvent;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\Files\Node; use OCP\Files\Node;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
...@@ -38,11 +39,12 @@ use OCP\SystemTag\ISystemTag; ...@@ -38,11 +39,12 @@ use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\MapperEvent; use OCP\SystemTag\MapperEvent;
use OCP\WorkflowEngine\EntityContext\IDisplayText; use OCP\WorkflowEngine\EntityContext\IDisplayText;
use OCP\WorkflowEngine\EntityContext\IUrl;
use OCP\WorkflowEngine\GenericEntityEvent; use OCP\WorkflowEngine\GenericEntityEvent;
use OCP\WorkflowEngine\IEntity; use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IRuleMatcher; use OCP\WorkflowEngine\IRuleMatcher;
class File implements IEntity, IDisplayText { class File implements IEntity, IDisplayText, IUrl {
private const EVENT_NAMESPACE = '\OCP\Files::'; private const EVENT_NAMESPACE = '\OCP\Files::';
...@@ -208,4 +210,14 @@ class File implements IEntity, IDisplayText { ...@@ -208,4 +210,14 @@ class File implements IEntity, IDisplayText {
return $this->l10n->t('%s assigned %s to %s', $options); 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 '';
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment