aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/bookmark/BookmarkInitializer.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/bookmark/BookmarkInitializer.php')
-rw-r--r--application/bookmark/BookmarkInitializer.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/application/bookmark/BookmarkInitializer.php b/application/bookmark/BookmarkInitializer.php
new file mode 100644
index 00000000..9eee9a35
--- /dev/null
+++ b/application/bookmark/BookmarkInitializer.php
@@ -0,0 +1,59 @@
1<?php
2
3namespace Shaarli\Bookmark;
4
5/**
6 * Class BookmarkInitializer
7 *
8 * This class is used to initialized default bookmarks after a fresh install of Shaarli.
9 * It is no longer call when the data store is empty,
10 * because user might want to delete default bookmarks after the install.
11 *
12 * To prevent data corruption, it does not overwrite existing bookmarks,
13 * even though there should not be any.
14 *
15 * @package Shaarli\Bookmark
16 */
17class BookmarkInitializer
18{
19 /** @var BookmarkServiceInterface */
20 protected $bookmarkService;
21
22 /**
23 * BookmarkInitializer constructor.
24 *
25 * @param BookmarkServiceInterface $bookmarkService
26 */
27 public function __construct($bookmarkService)
28 {
29 $this->bookmarkService = $bookmarkService;
30 }
31
32 /**
33 * Initialize the data store with default bookmarks
34 */
35 public function initialize()
36 {
37 $bookmark = new Bookmark();
38 $bookmark->setTitle(t('My secret stuff... - Pastebin.com'));
39 $bookmark->setUrl('http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=', []);
40 $bookmark->setDescription(t('Shhhh! I\'m a private link only YOU can see. You can delete me too.'));
41 $bookmark->setTagsString('secretstuff');
42 $bookmark->setPrivate(true);
43 $this->bookmarkService->add($bookmark);
44
45 $bookmark = new Bookmark();
46 $bookmark->setTitle(t('The personal, minimalist, super-fast, database free, bookmarking service'));
47 $bookmark->setUrl('https://shaarli.readthedocs.io', []);
48 $bookmark->setDescription(t(
49 'Welcome to Shaarli! This is your first public bookmark. '
50 . 'To edit or delete me, you must first login.
51
52To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
53
54You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
55 ));
56 $bookmark->setTagsString('opensource software');
57 $this->bookmarkService->add($bookmark);
58 }
59}