@@ -32,78 +32,78 @@ |
||
| 32 | 32 | |
| 33 | 33 | class Application extends \OCP\AppFramework\App { |
| 34 | 34 | |
| 35 | - const APP_ID = 'workflowengine'; |
|
| 35 | + const APP_ID = 'workflowengine'; |
|
| 36 | 36 | |
| 37 | - /** @var EventDispatcherInterface */ |
|
| 38 | - protected $dispatcher; |
|
| 39 | - /** @var Manager */ |
|
| 40 | - protected $manager; |
|
| 37 | + /** @var EventDispatcherInterface */ |
|
| 38 | + protected $dispatcher; |
|
| 39 | + /** @var Manager */ |
|
| 40 | + protected $manager; |
|
| 41 | 41 | |
| 42 | - public function __construct() { |
|
| 43 | - parent::__construct(self::APP_ID); |
|
| 42 | + public function __construct() { |
|
| 43 | + parent::__construct(self::APP_ID); |
|
| 44 | 44 | |
| 45 | - $this->getContainer()->registerAlias('RequestTimeController', RequestTime::class); |
|
| 45 | + $this->getContainer()->registerAlias('RequestTimeController', RequestTime::class); |
|
| 46 | 46 | |
| 47 | - $this->dispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
| 48 | - $this->manager = $this->getContainer()->query(Manager::class); |
|
| 49 | - } |
|
| 47 | + $this->dispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
| 48 | + $this->manager = $this->getContainer()->query(Manager::class); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Register all hooks and listeners |
|
| 53 | - */ |
|
| 54 | - public function registerHooksAndListeners() { |
|
| 55 | - $this->dispatcher->addListener( |
|
| 56 | - 'OCP\WorkflowEngine::loadAdditionalSettingScripts', |
|
| 57 | - function() { |
|
| 58 | - if (!function_exists('style')) { |
|
| 59 | - // This is hacky, but we need to load the template class |
|
| 60 | - class_exists(Template::class, true); |
|
| 61 | - } |
|
| 51 | + /** |
|
| 52 | + * Register all hooks and listeners |
|
| 53 | + */ |
|
| 54 | + public function registerHooksAndListeners() { |
|
| 55 | + $this->dispatcher->addListener( |
|
| 56 | + 'OCP\WorkflowEngine::loadAdditionalSettingScripts', |
|
| 57 | + function() { |
|
| 58 | + if (!function_exists('style')) { |
|
| 59 | + // This is hacky, but we need to load the template class |
|
| 60 | + class_exists(Template::class, true); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - style(self::APP_ID, [ |
|
| 64 | - 'admin', |
|
| 65 | - ]); |
|
| 63 | + style(self::APP_ID, [ |
|
| 64 | + 'admin', |
|
| 65 | + ]); |
|
| 66 | 66 | |
| 67 | - script('core', [ |
|
| 68 | - 'files/fileinfo', |
|
| 69 | - 'files/client', |
|
| 70 | - 'systemtags/systemtags', |
|
| 71 | - 'systemtags/systemtagmodel', |
|
| 72 | - 'systemtags/systemtagscollection', |
|
| 73 | - ]); |
|
| 67 | + script('core', [ |
|
| 68 | + 'files/fileinfo', |
|
| 69 | + 'files/client', |
|
| 70 | + 'systemtags/systemtags', |
|
| 71 | + 'systemtags/systemtagmodel', |
|
| 72 | + 'systemtags/systemtagscollection', |
|
| 73 | + ]); |
|
| 74 | 74 | |
| 75 | - script(self::APP_ID, [ |
|
| 76 | - 'workflowengine', |
|
| 77 | - ]); |
|
| 78 | - }, |
|
| 79 | - -100 |
|
| 80 | - ); |
|
| 81 | - } |
|
| 75 | + script(self::APP_ID, [ |
|
| 76 | + 'workflowengine', |
|
| 77 | + ]); |
|
| 78 | + }, |
|
| 79 | + -100 |
|
| 80 | + ); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function registerRuleListeners() { |
|
| 84 | - $configuredEvents = $this->manager->getAllConfiguredEvents(); |
|
| 83 | + public function registerRuleListeners() { |
|
| 84 | + $configuredEvents = $this->manager->getAllConfiguredEvents(); |
|
| 85 | 85 | |
| 86 | - foreach ($configuredEvents as $operationClass => $events) { |
|
| 87 | - foreach ($events as $entityClass => $eventNames) { |
|
| 88 | - array_map(function (string $eventName) use ($operationClass, $entityClass) { |
|
| 89 | - $this->dispatcher->addListener( |
|
| 90 | - $eventName, |
|
| 91 | - function (GenericEvent $event) use ($eventName, $operationClass, $entityClass) { |
|
| 92 | - $ruleMatcher = $this->manager->getRuleMatcher(); |
|
| 93 | - try { |
|
| 94 | - /** @var IEntity $entity */ |
|
| 95 | - $entity = $this->getContainer()->query($entityClass); |
|
| 96 | - $entity->prepareRuleMatcher($ruleMatcher, $eventName, $event); |
|
| 97 | - /** @var IOperation $operation */ |
|
| 98 | - $operation = $this->getContainer()->query($operationClass); |
|
| 99 | - $operation->onEvent($eventName, $event, $ruleMatcher); |
|
| 100 | - } catch (QueryException $e) { |
|
| 101 | - // Ignore query exceptions since they might occur when an entity/operation were setup before by an app that is disabled now |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - ); |
|
| 105 | - }, $eventNames); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 86 | + foreach ($configuredEvents as $operationClass => $events) { |
|
| 87 | + foreach ($events as $entityClass => $eventNames) { |
|
| 88 | + array_map(function (string $eventName) use ($operationClass, $entityClass) { |
|
| 89 | + $this->dispatcher->addListener( |
|
| 90 | + $eventName, |
|
| 91 | + function (GenericEvent $event) use ($eventName, $operationClass, $entityClass) { |
|
| 92 | + $ruleMatcher = $this->manager->getRuleMatcher(); |
|
| 93 | + try { |
|
| 94 | + /** @var IEntity $entity */ |
|
| 95 | + $entity = $this->getContainer()->query($entityClass); |
|
| 96 | + $entity->prepareRuleMatcher($ruleMatcher, $eventName, $event); |
|
| 97 | + /** @var IOperation $operation */ |
|
| 98 | + $operation = $this->getContainer()->query($operationClass); |
|
| 99 | + $operation->onEvent($eventName, $event, $ruleMatcher); |
|
| 100 | + } catch (QueryException $e) { |
|
| 101 | + // Ignore query exceptions since they might occur when an entity/operation were setup before by an app that is disabled now |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + ); |
|
| 105 | + }, $eventNames); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | } |
@@ -85,10 +85,10 @@ |
||
| 85 | 85 | |
| 86 | 86 | foreach ($configuredEvents as $operationClass => $events) { |
| 87 | 87 | foreach ($events as $entityClass => $eventNames) { |
| 88 | - array_map(function (string $eventName) use ($operationClass, $entityClass) { |
|
| 88 | + array_map(function(string $eventName) use ($operationClass, $entityClass) { |
|
| 89 | 89 | $this->dispatcher->addListener( |
| 90 | 90 | $eventName, |
| 91 | - function (GenericEvent $event) use ($eventName, $operationClass, $entityClass) { |
|
| 91 | + function(GenericEvent $event) use ($eventName, $operationClass, $entityClass) { |
|
| 92 | 92 | $ruleMatcher = $this->manager->getRuleMatcher(); |
| 93 | 93 | try { |
| 94 | 94 | /** @var IEntity $entity */ |