diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Notifications')
3 files changed, 191 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Notifications/Action.php b/src/Wallabag/CoreBundle/Notifications/Action.php new file mode 100644 index 00000000..8ef1860a --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/Action.php | |||
@@ -0,0 +1,84 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Notifications; | ||
4 | |||
5 | class Action implements ActionInterface { | ||
6 | |||
7 | /** | ||
8 | * @var string | ||
9 | */ | ||
10 | protected $label; | ||
11 | |||
12 | /** | ||
13 | * @var int | ||
14 | */ | ||
15 | protected $type; | ||
16 | |||
17 | const TYPE_OK = 1; | ||
18 | const TYPE_YES = 2; | ||
19 | const TYPE_NO = 3; | ||
20 | const TYPE_INFO = 4; | ||
21 | |||
22 | /** | ||
23 | * @var string | ||
24 | */ | ||
25 | protected $link; | ||
26 | |||
27 | /** | ||
28 | * @return string | ||
29 | */ | ||
30 | public function getLabel() | ||
31 | { | ||
32 | return $this->label; | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * @param string $label | ||
37 | * @return ActionInterface | ||
38 | */ | ||
39 | public function setLabel($label) | ||
40 | { | ||
41 | $this->label = $label; | ||
42 | return $this; | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * @return int | ||
47 | */ | ||
48 | public function getType() | ||
49 | { | ||
50 | return $this->type; | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * @param int $type | ||
55 | * @return ActionInterface | ||
56 | * @throws \InvalidArgumentException | ||
57 | */ | ||
58 | public function setType($type) | ||
59 | { | ||
60 | if ($type <= 0 || $type > 4) { | ||
61 | throw new \InvalidArgumentException('The given type option is invalid'); | ||
62 | } | ||
63 | $this->type = $type; | ||
64 | return $this; | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * @return string | ||
69 | */ | ||
70 | public function getLink() | ||
71 | { | ||
72 | return $this->link; | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * @param string $link | ||
77 | * @return ActionInterface | ||
78 | */ | ||
79 | public function setLink($link) | ||
80 | { | ||
81 | $this->link = $link; | ||
82 | return $this; | ||
83 | } | ||
84 | } | ||
diff --git a/src/Wallabag/CoreBundle/Notifications/ActionInterface.php b/src/Wallabag/CoreBundle/Notifications/ActionInterface.php new file mode 100644 index 00000000..0b40237d --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/ActionInterface.php | |||
@@ -0,0 +1,41 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Notifications; | ||
4 | |||
5 | interface ActionInterface { | ||
6 | |||
7 | /** | ||
8 | * @return string | ||
9 | */ | ||
10 | public function getLabel(); | ||
11 | |||
12 | /** | ||
13 | * @param string $label | ||
14 | * @return ActionInterface | ||
15 | */ | ||
16 | public function setLabel($label); | ||
17 | |||
18 | /** | ||
19 | * @return int | ||
20 | */ | ||
21 | public function getType(); | ||
22 | |||
23 | /** | ||
24 | * @param int $type | ||
25 | * @return ActionInterface | ||
26 | */ | ||
27 | public function setType($type); | ||
28 | |||
29 | /** | ||
30 | * @return string | ||
31 | */ | ||
32 | public function getLink(); | ||
33 | |||
34 | /** | ||
35 | * @param string $link | ||
36 | * @return ActionInterface | ||
37 | */ | ||
38 | public function setLink($link); | ||
39 | |||
40 | |||
41 | } | ||
diff --git a/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php b/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php new file mode 100644 index 00000000..d83e2361 --- /dev/null +++ b/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php | |||
@@ -0,0 +1,66 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Notifications; | ||
4 | |||
5 | use Psr\Log\LoggerAwareInterface; | ||
6 | |||
7 | interface NotificationInterface extends LoggerAwareInterface { | ||
8 | |||
9 | /** | ||
10 | * Title of the notification | ||
11 | * | ||
12 | * @return string | ||
13 | */ | ||
14 | public function getTitle(); | ||
15 | |||
16 | /** | ||
17 | * @param string $title | ||
18 | * @return NotificationInterface | ||
19 | */ | ||
20 | public function setTitle($title); | ||
21 | |||
22 | /** | ||
23 | * Type of the notification. | ||
24 | * | ||
25 | * @return string | ||
26 | */ | ||
27 | public function getType(); | ||
28 | |||
29 | /** | ||
30 | * @param int $type | ||
31 | * @return NotificationInterface | ||
32 | */ | ||
33 | public function setType($type); | ||
34 | |||
35 | /** | ||
36 | * If the notification has been viewed / dismissed or not | ||
37 | * | ||
38 | * @return boolean | ||
39 | */ | ||
40 | public function isRead(); | ||
41 | |||
42 | /** | ||
43 | * @param boolean $read | ||
44 | * @return NotificationInterface | ||
45 | */ | ||
46 | public function setRead($read); | ||
47 | |||
48 | /** | ||
49 | * When the notification was sent | ||
50 | * | ||
51 | * @return \DateTime | ||
52 | */ | ||
53 | public function getTimestamp(); | ||
54 | |||
55 | /** | ||
56 | * @param \DateTime $timestamp | ||
57 | * @return NotificationInterface | ||
58 | */ | ||
59 | public function setTimestamp(\DateTime $timestamp); | ||
60 | |||
61 | /** | ||
62 | * @param ActionInterface $action | ||
63 | * @return NotificationInterface | ||
64 | */ | ||
65 | public function addAction(ActionInterface $action); | ||
66 | } | ||