summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/lib/AppInfo/Application.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-11-06 10:54:37 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-11-13 14:23:39 +0100
commit2efe8aad38b83e0ec7f21b836f4e503045990213 (patch)
tree8ee6f6ea0f802687e27c7c5797154369206c109f /apps/workflowengine/lib/AppInfo/Application.php
parentd9204f61ead5f5c95cbef21a5d6fc40ac2d1861a (diff)
downloadnextcloud-server-2efe8aad38b83e0ec7f21b836f4e503045990213.tar.gz
nextcloud-server-2efe8aad38b83e0ec7f21b836f4e503045990213.zip
relax dependency on GenericEvent, instead stay compatible with old events
* also fixes tagging events Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/workflowengine/lib/AppInfo/Application.php')
-rw-r--r--apps/workflowengine/lib/AppInfo/Application.php32
1 files changed, 27 insertions, 5 deletions
diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php
index cea6ac7a1e5..8ac291b9289 100644
--- a/apps/workflowengine/lib/AppInfo/Application.php
+++ b/apps/workflowengine/lib/AppInfo/Application.php
@@ -23,12 +23,14 @@ namespace OCA\WorkflowEngine\AppInfo;
use OCA\WorkflowEngine\Manager;
use OCP\AppFramework\QueryException;
+use OCP\EventDispatcher\Event;
use OCP\Template;
use OCA\WorkflowEngine\Controller\RequestTime;
use OCP\WorkflowEngine\IEntity;
+use OCP\WorkflowEngine\IEntityCompat;
use OCP\WorkflowEngine\IOperation;
+use OCP\WorkflowEngine\IOperationCompat;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
class Application extends \OCP\AppFramework\App {
@@ -54,7 +56,7 @@ class Application extends \OCP\AppFramework\App {
public function registerHooksAndListeners() {
$this->dispatcher->addListener(
'OCP\WorkflowEngine::loadAdditionalSettingScripts',
- function() {
+ function () {
if (!function_exists('style')) {
// This is hacky, but we need to load the template class
class_exists(Template::class, true);
@@ -88,15 +90,35 @@ class Application extends \OCP\AppFramework\App {
array_map(function (string $eventName) use ($operationClass, $entityClass) {
$this->dispatcher->addListener(
$eventName,
- function (GenericEvent $event) use ($eventName, $operationClass, $entityClass) {
+ function ($event) use ($eventName, $operationClass, $entityClass) {
$ruleMatcher = $this->manager->getRuleMatcher();
try {
/** @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, $ruleMatcher);
+
+ if ($event instanceof Event) {
+ $entity->prepareRuleMatcher($ruleMatcher, $eventName, $event);
+ $operation->onEvent($eventName, $event, $ruleMatcher);
+ } else if ($entity instanceof IEntityCompat && $operation instanceof IOperationCompat) {
+ // TODO: Remove this block (and the compat classes) in the first major release in 2023
+ $entity->prepareRuleMatcherCompat($ruleMatcher, $eventName, $event);
+ $operation->onEventCompat($eventName, $event, $ruleMatcher);
+ } else {
+ $logger = $this->getContainer()->getServer()->getLogger();
+ $logger->warning(
+ 'Cannot handle event {name} of {event} against entity {entity} and operation {operation}',
+ [
+ 'app' => self::APP_ID,
+ 'name' => $eventName,
+ 'event' => get_class($event),
+ 'entity' => $entityClass,
+ 'operation' => $operationClass,
+ ]
+ );
+ }
+
} catch (QueryException $e) {
// Ignore query exceptions since they might occur when an entity/operation were setup before by an app that is disabled now
}