Skip to content

Commit

Permalink
flow file entity to provide the internal URL
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Dec 13, 2019
1 parent 6426067 commit f8394e3
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 f8394e3

Please sign in to comment.