aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Notifications
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Notifications')
-rw-r--r--src/Wallabag/CoreBundle/Notifications/Action.php91
-rw-r--r--src/Wallabag/CoreBundle/Notifications/ActionInterface.php42
-rw-r--r--src/Wallabag/CoreBundle/Notifications/InfoAction.php13
-rw-r--r--src/Wallabag/CoreBundle/Notifications/NoAction.php13
-rw-r--r--src/Wallabag/CoreBundle/Notifications/NotificationInterface.php103
-rw-r--r--src/Wallabag/CoreBundle/Notifications/OkAction.php13
-rw-r--r--src/Wallabag/CoreBundle/Notifications/YesAction.php13
7 files changed, 288 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..d032adf9
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/Action.php
@@ -0,0 +1,91 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class 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 *
38 * @return ActionInterface
39 */
40 public function setLabel($label)
41 {
42 $this->label = $label;
43
44 return $this;
45 }
46
47 /**
48 * @return int
49 */
50 public function getType()
51 {
52 return $this->type;
53 }
54
55 /**
56 * @param int $type
57 *
58 * @return ActionInterface
59 *
60 * @throws \InvalidArgumentException
61 */
62 public function setType($type)
63 {
64 if ($type <= 0 || $type > 4) {
65 throw new \InvalidArgumentException('The given type option is invalid');
66 }
67 $this->type = $type;
68
69 return $this;
70 }
71
72 /**
73 * @return string
74 */
75 public function getLink()
76 {
77 return $this->link;
78 }
79
80 /**
81 * @param string $link
82 *
83 * @return ActionInterface
84 */
85 public function setLink($link)
86 {
87 $this->link = $link;
88
89 return $this;
90 }
91}
diff --git a/src/Wallabag/CoreBundle/Notifications/ActionInterface.php b/src/Wallabag/CoreBundle/Notifications/ActionInterface.php
new file mode 100644
index 00000000..e166e45b
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/ActionInterface.php
@@ -0,0 +1,42 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5interface ActionInterface
6{
7 /**
8 * @return string
9 */
10 public function getLabel();
11
12 /**
13 * @param string $label
14 *
15 * @return ActionInterface
16 */
17 public function setLabel($label);
18
19 /**
20 * @return int
21 */
22 public function getType();
23
24 /**
25 * @param int $type
26 *
27 * @return ActionInterface
28 */
29 public function setType($type);
30
31 /**
32 * @return string
33 */
34 public function getLink();
35
36 /**
37 * @param string $link
38 *
39 * @return ActionInterface
40 */
41 public function setLink($link);
42}
diff --git a/src/Wallabag/CoreBundle/Notifications/InfoAction.php b/src/Wallabag/CoreBundle/Notifications/InfoAction.php
new file mode 100644
index 00000000..3006b04a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/InfoAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class InfoAction extends Action
6{
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'Info';
11 $this->type = Action::TYPE_INFO;
12 }
13}
diff --git a/src/Wallabag/CoreBundle/Notifications/NoAction.php b/src/Wallabag/CoreBundle/Notifications/NoAction.php
new file mode 100644
index 00000000..606372b6
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/NoAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class NoAction extends Action
6{
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'No';
11 $this->type = Action::TYPE_NO;
12 }
13}
diff --git a/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php b/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php
new file mode 100644
index 00000000..4a3c2759
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/NotificationInterface.php
@@ -0,0 +1,103 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5use Psr\Log\LoggerAwareInterface;
6
7interface 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 *
19 * @return NotificationInterface
20 */
21 public function setTitle($title);
22
23 /**
24 * Type of the notification.
25 *
26 * @return string
27 */
28 public function getType();
29
30 /**
31 * @param int $type
32 *
33 * @return NotificationInterface
34 */
35 public function setType($type);
36
37 /**
38 * If the notification has been viewed / dismissed or not.
39 *
40 * @return bool
41 */
42 public function isRead();
43
44 /**
45 * @param bool $read
46 *
47 * @return NotificationInterface
48 */
49 public function setRead($read);
50
51 /**
52 * When the notification was sent.
53 *
54 * @return \DateTime
55 */
56 public function getTimestamp();
57
58 /**
59 * @param \DateTime $timestamp
60 *
61 * @return NotificationInterface
62 */
63 public function setTimestamp(\DateTime $timestamp);
64
65 /**
66 * @param ActionInterface $action
67 *
68 * @return NotificationInterface
69 */
70 public function addAction(ActionInterface $action);
71
72 /**
73 * @return string
74 */
75 public function getDescription();
76
77 /**
78 * @param string $description
79 *
80 * @return NotificationInterface
81 */
82 public function setDescription($description);
83
84 /**
85 * @return array
86 */
87 public function getParameters();
88
89 /**
90 * @param array $parameters
91 *
92 * @return NotificationInterface
93 */
94 public function setParameters($parameters);
95
96 /**
97 * @param string $key
98 * @param string $value
99 *
100 * @return NotificationInterface
101 */
102 public function addParameter($key, $value);
103}
diff --git a/src/Wallabag/CoreBundle/Notifications/OkAction.php b/src/Wallabag/CoreBundle/Notifications/OkAction.php
new file mode 100644
index 00000000..521e6742
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/OkAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class OkAction extends Action
6{
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'OK';
11 $this->type = Action::TYPE_OK;
12 }
13}
diff --git a/src/Wallabag/CoreBundle/Notifications/YesAction.php b/src/Wallabag/CoreBundle/Notifications/YesAction.php
new file mode 100644
index 00000000..9b48eca5
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/YesAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class YesAction extends Action
6{
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'Yes';
11 $this->type = Action::TYPE_YES;
12 }
13}