summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/workflowengine/lib/AppInfo/Application.php11
-rw-r--r--apps/workflowengine/lib/Entity/File.php19
2 files changed, 27 insertions, 3 deletions
diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php
index e691c53d528..f5653a6e48c 100644
--- a/apps/workflowengine/lib/AppInfo/Application.php
+++ b/apps/workflowengine/lib/AppInfo/Application.php
@@ -24,6 +24,7 @@ namespace OCA\WorkflowEngine\AppInfo;
use OCA\WorkflowEngine\Manager;
use OCP\Template;
use OCA\WorkflowEngine\Controller\RequestTime;
+use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IOperation;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -83,13 +84,17 @@ class Application extends \OCP\AppFramework\App {
foreach ($configuredEvents as $operationClass => $events) {
foreach ($events as $entityClass => $eventNames) {
- array_map(function (string $eventName) use ($operationClass) {
+ array_map(function (string $eventName) use ($operationClass, $entityClass) {
$this->dispatcher->addListener(
$eventName,
- function (GenericEvent $event) use ($eventName, $operationClass) {
+ function (GenericEvent $event) use ($eventName, $operationClass, $entityClass) {
+ $ruleMatcher = $this->manager->getRuleMatcher();
+ /** @var IEntity $entity */
+ $entity = $this->getContainer()->query($entityClass);
+ $entity->prepareRuleMatcher($ruleMatcher, $eventName, $event);
/** @var IOperation $operation */
$operation = $this->getContainer()->query($operationClass);
- $operation->onEvent($eventName, $event);
+ $operation->onEvent($eventName, $event, $ruleMatcher);
}
);
}, $eventNames);
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]);
+ }
+ }
}