1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- declare(strict_types=1);
- namespace OC\Preview;
- use OC\SystemConfig;
- use OCP\Files\IRootFolder;
- use OCP\Files\Node;
- class WatcherConnector {
-
- private $root;
-
- private $config;
-
- public function __construct(IRootFolder $root,
- SystemConfig $config) {
- $this->root = $root;
- $this->config = $config;
- }
-
- private function getWatcher(): Watcher {
- return \OCP\Server::get(Watcher::class);
- }
- public function connectWatcher() {
-
- 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');
- }
- }
- }
|