3 namespace Shaarli\Bookmark
;
6 use Shaarli\Bookmark\Exception\BookmarkNotFoundException
;
7 use Shaarli\Bookmark\Exception\NotWritableDataStoreException
;
8 use Shaarli\Config\ConfigManager
;
12 * Class BookmarksService
14 * This is the entry point to manipulate the bookmark DB.
16 interface BookmarkServiceInterface
19 * BookmarksService constructor.
21 * @param ConfigManager $conf instance
22 * @param History $history instance
23 * @param bool $isLoggedIn true if the current user is logged in
25 public function __construct(ConfigManager
$conf, History
$history, $isLoggedIn);
28 * Find a bookmark by hash
36 public function findByHash($hash);
41 * @return Bookmark|null
43 public function findByUrl($url);
48 * @param mixed $request
49 * @param string $visibility
50 * @param bool $caseSensitive
51 * @param bool $untaggedOnly
52 * @param bool $ignoreSticky
56 public function search(
59 $caseSensitive = false,
60 $untaggedOnly = false,
61 bool $ignoreSticky = false
65 * Get a single bookmark by its ID.
67 * @param int $id Bookmark ID
68 * @param string $visibility all|public|private e.g. with public, accessing a private bookmark will throw an
73 * @throws BookmarkNotFoundException
76 public function get($id, $visibility = null);
79 * Updates an existing bookmark (depending on its ID).
81 * @param Bookmark $bookmark
82 * @param bool $save Writes to the datastore if set to true
84 * @return Bookmark Updated bookmark
86 * @throws BookmarkNotFoundException
89 public function set($bookmark, $save = true);
92 * Adds a new bookmark (the ID must be empty).
94 * @param Bookmark $bookmark
95 * @param bool $save Writes to the datastore if set to true
97 * @return Bookmark new bookmark
101 public function add($bookmark, $save = true);
104 * Adds or updates a bookmark depending on its ID:
105 * - a Bookmark without ID will be added
106 * - a Bookmark with an existing ID will be updated
108 * @param Bookmark $bookmark
115 public function addOrSet($bookmark, $save = true);
118 * Deletes a bookmark.
120 * @param Bookmark $bookmark
125 public function remove($bookmark, $save = true);
128 * Get a single bookmark by its ID.
130 * @param int $id Bookmark ID
131 * @param string $visibility all|public|private e.g. with public, accessing a private bookmark will throw an
136 public function exists($id, $visibility = null);
139 * Return the number of available bookmarks for given visibility.
141 * @param string $visibility public|private|all
143 * @return int Number of bookmarks
145 public function count($visibility = null);
148 * Write the datastore.
150 * @throws NotWritableDataStoreException
152 public function save();
155 * Returns the list tags appearing in the bookmarks with the given tags
157 * @param array $filteringTags tags selecting the bookmarks to consider
158 * @param string $visibility process only all/private/public bookmarks
160 * @return array tag => bookmarksCount
162 public function bookmarksCountPerTag($filteringTags = [], $visibility = 'all');
165 * Returns the list of days containing articles (oldest first)
167 * @return array containing days (in format YYYYMMDD).
169 public function days();
172 * Returns the list of articles for a given day.
174 * @param string $request day to filter. Format: YYYYMMDD.
176 * @return Bookmark[] list of shaare found.
178 * @throws BookmarkNotFoundException
180 public function filterDay($request);
183 * Creates the default database after a fresh install.
185 public function initialize();