PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Entity / Notification / Notification.php

Notification.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/Entity/Notification/Notification.php

256 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © Melograno Venture Studio. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace IvyForms\Entity\Notification;
9
10 use IvyForms\ValueObjects\Notification\Notification as NotificationValueObject;
11
12 /**
13 * Class Notification
14 *
15 * @package IvyForms\Entity\Notification
16 */
17 class Notification
18 {
19 /**
20 * @var NotificationValueObject
21 */
22 private NotificationValueObject $notification;
23
24 /**
25 * @var NotificationContact
26 */
27 private NotificationContact $contact;
28
29 /**
30 * Opaque extension payload (Pro / add-ons). Not owned by Lite domain fields.
31 *
32 * @var array<string, mixed>
33 */
34 private array $extensionData = [];
35
36 /**
37 * Notification constructor.
38 *
39 * @param NotificationValueObject $notification The notification object.
40 */
41 public function __construct(NotificationValueObject $notification)
42 {
43 $this->notification = $notification;
44 $this->contact = new NotificationContact($notification->contact);
45 }
46
47 /**
48 * @param array<string, mixed> $data
49 */
50 public function setExtensionData(array $data): void
51 {
52 $this->extensionData = $data;
53 }
54
55 /**
56 * @return array<string, mixed>
57 */
58 public function getExtensionData(): array
59 {
60 return $this->extensionData;
61 }
62
63 /**
64 * Get the notification ID.
65 *
66 * @return int
67 */
68 public function getId(): int
69 {
70 return $this->notification->getId();
71 }
72
73 /**
74 * Set the notification ID.
75 *
76 * @param int $id
77 */
78 public function setId(int $id): void
79 {
80 $this->notification->id = $id;
81 }
82
83 /**
84 * Get the notification name.
85 *
86 * @return string
87 */
88 public function getName(): string
89 {
90 return $this->notification->getName();
91 }
92
93 /**
94 * Set the notification name.
95 *
96 * @param string $name
97 */
98 public function setName(string $name): void
99 {
100 $this->notification->name = $name;
101 }
102
103 /**
104 * Get the NotificationContact entity.
105 *
106 * @return NotificationContact
107 */
108 public function getNotificationContact(): NotificationContact
109 {
110 return $this->contact;
111 }
112
113 /**
114 * Get the notification status.
115 *
116 * @return bool
117 */
118 public function isEnabled(): bool
119 {
120 return $this->notification->isEnabled();
121 }
122
123 /**
124 * Set the notification status.
125 *
126 * @param bool $enabled
127 */
128 public function setEnabled(bool $enabled): void
129 {
130 $this->notification->enabled = $enabled;
131 }
132
133 /**
134 * Get the notification subject.
135 *
136 * @return string
137 */
138 public function getSubject(): string
139 {
140 return $this->notification->getSubject();
141 }
142
143 /**
144 * Set the notification subject.
145 *
146 * @param string $subject
147 */
148 public function setSubject(string $subject): void
149 {
150 $this->notification->subject = $subject;
151 }
152
153 /**
154 * Get the notification message.
155 *
156 * @return string
157 */
158 public function getMessage(): string
159 {
160 return $this->notification->getMessage();
161 }
162
163 /**
164 * Set the notification message.
165 *
166 * @param string $message
167 */
168 public function setMessage(string $message): void
169 {
170 $this->notification->message = $message;
171 }
172
173 /**
174 * Get the show empty fields status.
175 *
176 * @return bool
177 */
178 public function isShowEmptyFields(): bool
179 {
180 return $this->notification->isShowEmptyFields();
181 }
182
183 /**
184 * Set the show empty fields status.
185 *
186 * @param bool $showEmptyFields
187 */
188 public function setShowEmptyFields(bool $showEmptyFields): void
189 {
190 $this->notification->showEmptyFields = $showEmptyFields;
191 }
192
193 /**
194 * Get the smart logic status.
195 *
196 * @return array<string, mixed>
197 */
198 public function getSmartLogic(): array
199 {
200 return $this->notification->getSmartLogic();
201 }
202
203 /**
204 * Set the smart logic status.
205 *
206 * @param array<string, mixed> $smartLogic
207 */
208 public function setSmartLogic(array $smartLogic): void
209 {
210 $this->notification->smartLogic = $smartLogic;
211 }
212
213 /**
214 * Get the form ID.
215 *
216 * @return int
217 */
218 public function getFormId(): int
219 {
220 return $this->notification->getFormId();
221 }
222
223 /**
224 * Set the form ID.
225 *
226 * @param int $formId
227 */
228 public function setFormId(int $formId): void
229 {
230 $this->notification->formId = $formId;
231 }
232
233 /**
234 * Convert the notification entity to an array.
235 *
236 * @return array<string, mixed> The notification entity as an array.
237 */
238 public function toArray(): array
239 {
240 return array_merge(
241 [
242 'id' => $this->getId(),
243 'name' => $this->getName(),
244 'enabled' => $this->isEnabled(),
245 'subject' => $this->getSubject(),
246 'message' => $this->getMessage(),
247 'showEmptyFields' => $this->isShowEmptyFields(),
248 'smartLogic' => $this->getSmartLogic(),
249 'formId' => $this->getFormId(),
250 ],
251 $this->getNotificationContact()->toArray(),
252 $this->extensionData
253 );
254 }
255 }
256