]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - application/bookmark/BookmarkInitializer.php
cd2d1724c1ad088193ffe51c1bde44a7d4ab2c2b
[github/shaarli/Shaarli.git] / application / bookmark / BookmarkInitializer.php
1 <?php
2
3 namespace 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 should be only called if the datastore file does not exist(users might want to delete the default bookmarks).
10 *
11 * To prevent data corruption, it does not overwrite existing bookmarks,
12 * even though there should not be any.
13 *
14 * @package Shaarli\Bookmark
15 */
16 class BookmarkInitializer
17 {
18 /** @var BookmarkServiceInterface */
19 protected $bookmarkService;
20
21 /**
22 * BookmarkInitializer constructor.
23 *
24 * @param BookmarkServiceInterface $bookmarkService
25 */
26 public function __construct($bookmarkService)
27 {
28 $this->bookmarkService = $bookmarkService;
29 }
30
31 /**
32 * Initialize the data store with default bookmarks
33 */
34 public function initialize()
35 {
36 $bookmark = new Bookmark();
37 $bookmark->setTitle(t('My secret stuff... - Pastebin.com'));
38 $bookmark->setUrl('http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=');
39 $bookmark->setDescription(t('Shhhh! I\'m a private link only YOU can see. You can delete me too.'));
40 $bookmark->setTagsString('secretstuff');
41 $bookmark->setPrivate(true);
42 $this->bookmarkService->add($bookmark, false);
43
44 $bookmark = new Bookmark();
45 $bookmark->setTitle(t('The personal, minimalist, super-fast, database free, bookmarking service'));
46 $bookmark->setUrl('https://shaarli.readthedocs.io', []);
47 $bookmark->setDescription(t(
48 'Welcome to Shaarli! This is your first public bookmark. '
49 . 'To edit or delete me, you must first login.
50
51 To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
52
53 You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
54 ));
55 $bookmark->setTagsString('opensource software');
56 $this->bookmarkService->add($bookmark, false);
57 }
58 }