Skip to content

Bookmark API

BookmarkService enables you to read, add and remove bookmarks from content.

Bookmark REST API

To learn how to manage bookmarks using the REST API, see REST API reference.

To view a list of all bookmarks, use BookmarkService::loadBookmarks:

1
2
3
4
5
6
7
        $bookmarkList = $this->bookmarkService->loadBookmarks();

        $output->writeln('Total bookmarks: ' . $bookmarkList->totalCount);

        foreach ($bookmarkList->items as $bookmark) {
            $output->writeln($bookmark->getContentInfo()->name);
        }

You can add a bookmark to a content item by providing its Location object to the BookmarkService::createBookmark method:

1
2
3
        $location = $this->locationService->loadLocation($locationId);

        $this->bookmarkService->createBookmark($location);

You can remove a bookmark from a Location with BookmarkService::deleteBookmark:

1
            $this->bookmarkService->deleteBookmark($location);