server = $server; $this->server->on('propFind', [$this, 'collectionPreloadNotifier' ], 1); } /** * Uses the server instance to emit a `preloadCollection` event to signal * to interested plugins that a collection can be preloaded. * * NOTE: this can be emitted several times, so ideally every plugin * should cache what they need and check if a cache exists before * re-fetching. */ public function collectionPreloadNotifier(PropFind $propFind, INode $node): bool { if (!$this->shouldPreload($propFind, $node)) { return true; } return $this->server->emit('preloadCollection', [$propFind, $node]); } private function shouldPreload( PropFind $propFind, INode $node, ): bool { $depth = $propFind->getDepth(); return $node instanceof ICollection && ($depth === Server::DEPTH_INFINITY || $depth > 0); } }