]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/bookmark/BookmarkInitializer.php
Remove anonymous permission and initialize bookmarks on login
[github/shaarli/Shaarli.git] / application / bookmark / BookmarkInitializer.php
CommitLineData
336a28fa
A
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.
d6e5f04d 9 * It should be only called if the datastore file does not exist(users might want to delete the default bookmarks).
336a28fa
A
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 */
16class 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'));
c4ad3d4f 38 $bookmark->setUrl('http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=');
336a28fa
A
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);
c4ad3d4f 42 $this->bookmarkService->add($bookmark, false);
336a28fa
A
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
51To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
52
53You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
54 ));
55 $bookmark->setTagsString('opensource software');
c4ad3d4f 56 $this->bookmarkService->add($bookmark, false);
336a28fa
A
57 }
58}