3 namespace Shaarli\Bookmark
;
6 use Shaarli\Bookmark\Exception\BookmarkNotFoundException
;
7 use Shaarli\Bookmark\Exception\NotWritableDataStoreException
;
10 * Class BookmarksService
12 * This is the entry point to manipulate the bookmark DB.
14 interface BookmarkServiceInterface
17 * Find a bookmark by hash
25 public function findByHash($hash);
30 * @return Bookmark|null
32 public function findByUrl($url);
37 * @param mixed $request
38 * @param string $visibility
39 * @param bool $caseSensitive
40 * @param bool $untaggedOnly
41 * @param bool $ignoreSticky
45 public function search(
48 $caseSensitive = false,
49 $untaggedOnly = false,
50 bool $ignoreSticky = false
54 * Get a single bookmark by its ID.
56 * @param int $id Bookmark ID
57 * @param string $visibility all|public|private e.g. with public, accessing a private bookmark will throw an
62 * @throws BookmarkNotFoundException
65 public function get($id, $visibility = null);
68 * Updates an existing bookmark (depending on its ID).
70 * @param Bookmark $bookmark
71 * @param bool $save Writes to the datastore if set to true
73 * @return Bookmark Updated bookmark
75 * @throws BookmarkNotFoundException
78 public function set($bookmark, $save = true);
81 * Adds a new bookmark (the ID must be empty).
83 * @param Bookmark $bookmark
84 * @param bool $save Writes to the datastore if set to true
86 * @return Bookmark new bookmark
90 public function add($bookmark, $save = true);
93 * Adds or updates a bookmark depending on its ID:
94 * - a Bookmark without ID will be added
95 * - a Bookmark with an existing ID will be updated
97 * @param Bookmark $bookmark
104 public function addOrSet($bookmark, $save = true);
107 * Deletes a bookmark.
109 * @param Bookmark $bookmark
114 public function remove($bookmark, $save = true);
117 * Get a single bookmark by its ID.
119 * @param int $id Bookmark ID
120 * @param string $visibility all|public|private e.g. with public, accessing a private bookmark will throw an
125 public function exists($id, $visibility = null);
128 * Return the number of available bookmarks for given visibility.
130 * @param string $visibility public|private|all
132 * @return int Number of bookmarks
134 public function count($visibility = null);
137 * Write the datastore.
139 * @throws NotWritableDataStoreException
141 public function save();
144 * Returns the list tags appearing in the bookmarks with the given tags
146 * @param array $filteringTags tags selecting the bookmarks to consider
147 * @param string $visibility process only all/private/public bookmarks
149 * @return array tag => bookmarksCount
151 public function bookmarksCountPerTag($filteringTags = [], $visibility = 'all');
154 * Returns the list of days containing articles (oldest first)
156 * @return array containing days (in format YYYYMMDD).
158 public function days();
161 * Returns the list of articles for a given day.
163 * @param string $request day to filter. Format: YYYYMMDD.
165 * @return Bookmark[] list of shaare found.
167 * @throws BookmarkNotFoundException
169 public function filterDay($request);
172 * Creates the default database after a fresh install.
174 public function initialize();