3 namespace Shaarli\Bookmark
;
6 use Shaarli\Bookmark\Exception\BookmarkNotFoundException
;
7 use Shaarli\Bookmark\Exception\NotWritableDataStoreException
;
8 use Shaarli\Config\ConfigManager
;
9 use Shaarli\Exceptions\IOException
;
13 * Class BookmarksService
15 * This is the entry point to manipulate the bookmark DB.
17 interface BookmarkServiceInterface
20 * BookmarksService constructor.
22 * @param ConfigManager $conf instance
23 * @param History $history instance
24 * @param bool $isLoggedIn true if the current user is logged in
26 public function __construct(ConfigManager
$conf, History
$history, $isLoggedIn);
29 * Find a bookmark by hash
37 public function findByHash($hash);
42 * @return Bookmark|null
44 public function findByUrl($url);
49 * @param mixed $request
50 * @param string $visibility
51 * @param bool $caseSensitive
52 * @param bool $untaggedOnly
56 public function search($request = [], $visibility = null, $caseSensitive = false, $untaggedOnly = false);
59 * Get a single bookmark by its ID.
61 * @param int $id Bookmark ID
62 * @param string $visibility all|public|private e.g. with public, accessing a private bookmark will throw an
67 * @throws BookmarkNotFoundException
70 public function get($id, $visibility = null);
73 * Updates an existing bookmark (depending on its ID).
75 * @param Bookmark $bookmark
76 * @param bool $save Writes to the datastore if set to true
78 * @return Bookmark Updated bookmark
80 * @throws BookmarkNotFoundException
83 public function set($bookmark, $save = true);
86 * Adds a new bookmark (the ID must be empty).
88 * @param Bookmark $bookmark
89 * @param bool $save Writes to the datastore if set to true
91 * @return Bookmark new bookmark
95 public function add($bookmark, $save = true);
98 * Adds or updates a bookmark depending on its ID:
99 * - a Bookmark without ID will be added
100 * - a Bookmark with an existing ID will be updated
102 * @param Bookmark $bookmark
109 public function addOrSet($bookmark, $save = true);
112 * Deletes a bookmark.
114 * @param Bookmark $bookmark
119 public function remove($bookmark, $save = true);
122 * Get a single bookmark by its ID.
124 * @param int $id Bookmark ID
125 * @param string $visibility all|public|private e.g. with public, accessing a private bookmark will throw an
130 public function exists($id, $visibility = null);
133 * Return the number of available bookmarks for given visibility.
135 * @param string $visibility public|private|all
137 * @return int Number of bookmarks
139 public function count($visibility = null);
142 * Write the datastore.
144 * @throws NotWritableDataStoreException
146 public function save();
149 * Returns the list tags appearing in the bookmarks with the given tags
151 * @param array $filteringTags tags selecting the bookmarks to consider
152 * @param string $visibility process only all/private/public bookmarks
154 * @return array tag => bookmarksCount
156 public function bookmarksCountPerTag($filteringTags = [], $visibility = 'all');
159 * Returns the list of days containing articles (oldest first)
161 * @return array containing days (in format YYYYMMDD).
163 public function days();
166 * Returns the list of articles for a given day.
168 * @param string $request day to filter. Format: YYYYMMDD.
170 * @return Bookmark[] list of shaare found.
172 * @throws BookmarkNotFoundException
174 public function filterDay($request);
177 * Creates the default database after a fresh install.
179 public function initialize();