MCPcopy Create free account
hub / github.com/Rello/analytics / onEvent

Method onEvent

lib/Flow/Operation.php:60–92  ·  view source on GitHub ↗
(string $eventName, Event $event, IRuleMatcher $ruleMatcher)

Source from the content-addressed store, hash-verified

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 = [

Callers

nothing calls this directly

Calls 4

parseOperationMethod · 0.95
getSubjectMethod · 0.45
executeMethod · 0.45
importFileMethod · 0.45

Tested by

no test coverage detected