on('preloadCollection', $this->preloadCollection(...)); $server->on('propFind', [$this, 'propFind']); } private function preloadCollection( PropFind $propFind, ICollection $collection, ): void { if ($collection instanceof Directory && $propFind->getStatus( static::REMINDER_DUE_DATE_PROPERTY ) !== null) { $folder = $collection->getNode(); $this->cacheFolder($folder); } } public function propFind(PropFind $propFind, INode $node) { if (!in_array(static::REMINDER_DUE_DATE_PROPERTY, $propFind->getRequestedProperties())) { return; } if (!($node instanceof Node)) { return; } $propFind->handle( static::REMINDER_DUE_DATE_PROPERTY, function () use ($node) { $user = $this->userSession->getUser(); if (!($user instanceof IUser)) { return ''; } $fileId = $node->getId(); $reminder = $this->reminderService->getDueForUser($user, $fileId, false); if ($reminder === null) { return ''; } return $reminder->getDueDate()->format(DateTimeInterface::ATOM); // ISO 8601 }, ); } private function cacheFolder(Folder $folder): void { $user = $this->userSession->getUser(); if (!($user instanceof IUser)) { return; } $this->reminderService->cacheFolder($user, $folder); } }