(string $eventName, Event $event, IRuleMatcher $ruleMatcher)
| 58 | } |
| 59 | |
| 60 | public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void { |
| 61 | $flow = $ruleMatcher->getFlows(); |
| 62 | if ($flow === []) { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | $operation = $this->parseOperation($flow['operation']); |
| 67 | |
| 68 | if ($eventName === '\OCP\Files::postRename') { |
| 69 | /** @var Node $oldNode */ |
| 70 | list(, $node) = $event->getSubject(); |
| 71 | } else { |
| 72 | $node = $event->getSubject(); |
| 73 | } |
| 74 | |
| 75 | list(, , $folder, $file) = explode('/', $node->getPath(), 4); |
| 76 | if ($folder !== 'files' || $node instanceof Folder) { |
| 77 | return; |
| 78 | } |
| 79 | $file = '/' . $file; |
| 80 | |
| 81 | try { |
| 82 | if ($operation['dataloadId'] !== 0) { |
| 83 | $this->DataloadController->execute($operation['dataloadId'], $file); |
| 84 | } else { |
| 85 | $this->DataloadController->importFile($operation['datasetId'], $file, true); |
| 86 | } |
| 87 | } catch (NotFoundException $e) { |
| 88 | return; |
| 89 | } catch (\Exception $e) { |
| 90 | return; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | private function parseOperation($operation): array { |
| 95 | $flowOperation = [ |
nothing calls this directly
no test coverage detected