+
+ public function readUpdates(string $updatesFilepath): array
+ {
+ return UpdaterUtils::read_updates_file($updatesFilepath);
+ }
+
+ public function writeUpdates(string $updatesFilepath, array $updates): void
+ {
+ UpdaterUtils::write_updates_file($updatesFilepath, $updates);
+ }
+
+ /**
+ * With the Slim routing system, default header link should be `/subfolder/` instead of `?`.
+ * Otherwise you can not go back to the home page.
+ * Example: `/subfolder/picture-wall` -> `/subfolder/picture-wall?` instead of `/subfolder/`.
+ */
+ public function updateMethodRelativeHomeLink(): bool
+ {
+ if ('?' === trim($this->conf->get('general.header_link'))) {
+ $this->conf->set('general.header_link', $this->basePath . '/', true, true);
+ }
+
+ return true;
+ }
+
+ /**
+ * With the Slim routing system, note bookmarks URL formatted `?abcdef`
+ * should be replaced with `/shaare/abcdef`
+ */
+ public function updateMethodMigrateExistingNotesUrl(): bool
+ {
+ $updated = false;
+
+ foreach ($this->bookmarkService->search() as $bookmark) {
+ if (
+ $bookmark->isNote()
+ && startsWith($bookmark->getUrl(), '?')
+ && 1 === preg_match('/^\?([a-zA-Z0-9-_@]{6})($|&|#)/', $bookmark->getUrl(), $match)
+ ) {
+ $updated = true;
+ $bookmark = $bookmark->setUrl('/shaare/' . $match[1]);
+
+ $this->bookmarkService->set($bookmark, false);
+ }
+ }
+
+ if ($updated) {
+ $this->bookmarkService->save();
+ }
+
+ return true;
+ }
+
+ public function setBasePath(string $basePath): self
+ {
+ $this->basePath = $basePath;
+
+ return $this;
+ }