bookmarkMapper = $bookmarkMapper; } /** * @brief get bookmark * * bookmark type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc * * @return SerializedEntity[] */ public function get(int $fileId, ?string $name = null, ?string $type = null): array { $result = $this->bookmarkMapper->get($fileId, $name, $type); return array_map( function (ReaderEntity $entity): array { return $entity->toService(); }, $result ); } /** * @brief write bookmark * * position type is format-dependent, eg CFI for epub, page number for CBR/CBZ, etc */ public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): ReaderEntity { return $this->bookmarkMapper->set($fileId, $name, $value, $type, $content); } /** * @brief get cursor (current position in book) * * @return SerializedEntity */ public function getCursor(int $fileId): array { $result = $this->get($fileId, self::CURSOR); if (1 === count($result)) { return $result[0]; } return []; } /** * @brief set cursor (current position in book) */ public function setCursor(int $fileId, string $value): ReaderEntity { return $this->bookmarkMapper->set($fileId, self::CURSOR, $value, self::BOOKMARK_TYPE); } /** * @brief delete bookmark */ public function delete(int $fileId, ?string $name = null, ?string $type = null): void { foreach ($this->bookmarkMapper->get($fileId, $name, $type) as $bookmark) { $this->bookmarkMapper->delete($bookmark); } } /** * @brief delete cursor */ public function deleteCursor(int $fileId): void { $this->delete($fileId, self::CURSOR, self::BOOKMARK_TYPE); } }