From ae1cc1d14dda99f62714d5e658e6cb71378aaae2 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 9 Sep 2019 17:17:39 +0200 Subject: entities equip the RuleMatcher on the events they are aware of Operations will receive the matcher instance Signed-off-by: Arthur Schiwon --- apps/workflowengine/lib/Entity/File.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'apps/workflowengine/lib/Entity') diff --git a/apps/workflowengine/lib/Entity/File.php b/apps/workflowengine/lib/Entity/File.php index b420217c4b6..dd15b0fd435 100644 --- a/apps/workflowengine/lib/Entity/File.php +++ b/apps/workflowengine/lib/Entity/File.php @@ -28,6 +28,8 @@ use OCP\IL10N; use OCP\IURLGenerator; use OCP\WorkflowEngine\GenericEntityEvent; use OCP\WorkflowEngine\IEntity; +use OCP\WorkflowEngine\IRuleMatcher; +use Symfony\Component\EventDispatcher\GenericEvent; class File implements IEntity { @@ -60,4 +62,21 @@ class File implements IEntity { new GenericEntityEvent($this->l10n->t('File copied'), $namespace . 'postCopy' ), ]; } + + /** + * @since 18.0.0 + */ + public function prepareRuleMatcher(IRuleMatcher $ruleMatcher, string $eventName, GenericEvent $event): void { + switch ($eventName) { + case 'postCreate': + case 'postWrite': + case 'postDelete': + case 'postTouch': + $ruleMatcher->setEntitySubject($this, $event->getSubject()); + break; + case 'postRename': + case 'postCopy': + $ruleMatcher->setEntitySubject($this, $event->getSubject()[1]); + } + } } -- cgit v1.2.3