root = $root; $this->config = $config; } /** * @return Watcher */ private function getWatcher(): Watcher { return \OCP\Server::get(Watcher::class); } public function connectWatcher() { // Do not connect if we are not setup yet! if ($this->config->getValue('instanceid', null) !== null) { $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { $this->getWatcher()->postWrite($node); }); \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); } } }