Skip to content

Commit

Permalink
Merge pull request #18162 from nextcloud/enh/noid/url-fileentity
Browse files Browse the repository at this point in the history
flow file entity to provide the internal URL
  • Loading branch information
blizzz authored Dec 19, 2019
2 parents eaf89d1 + f8394e3 commit 5a986f0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion apps/workflowengine/lib/Entity/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\GenericEvent;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
Expand All @@ -38,11 +39,12 @@
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::';

Expand Down Expand Up @@ -208,4 +210,14 @@ public function getDisplayText(int $verbosity = 0): string {
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 comments on commit 5a986f0

Please sign in to comment.