]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - application/bookmark/BookmarkInitializer.php
Process Shaarli install through Slim controller
[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 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 */
17 class 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 $this->bookmarkService->enableAnonymousPermission();
38
39 $bookmark = new Bookmark();
40 $bookmark->setTitle(t('My secret stuff... - Pastebin.com'));
41 $bookmark->setUrl('http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=');
42 $bookmark->setDescription(t('Shhhh! I\'m a private link only YOU can see. You can delete me too.'));
43 $bookmark->setTagsString('secretstuff');
44 $bookmark->setPrivate(true);
45 $this->bookmarkService->add($bookmark, false);
46
47 $bookmark = new Bookmark();
48 $bookmark->setTitle(t('The personal, minimalist, super-fast, database free, bookmarking service'));
49 $bookmark->setUrl('https://shaarli.readthedocs.io', []);
50 $bookmark->setDescription(t(
51 'Welcome to Shaarli! This is your first public bookmark. '
52 . 'To edit or delete me, you must first login.
53
54 To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
55
56 You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
57 ));
58 $bookmark->setTagsString('opensource software');
59 $this->bookmarkService->add($bookmark, false);
60
61 $this->bookmarkService->save();
62
63 $this->bookmarkService->disableAnonymousPermission();
64 }
65 }