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 <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Nov 29, 2019
1 parent 6a940d5 commit cf9b294
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 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,16 @@ 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->getAbsoluteURL('/f/' . $this->getNode()->getId());
return $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $this->getNode()->getId()]);
return $this->urlGenerator->getBaseUrl() . '/f/' . $this->getNode()->getId();
} catch (InvalidPathException $e) {
return '';
} catch (NotFoundException $e) {
return '';
}
}
}

0 comments on commit cf9b294

Please sign in to comment.