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
← All changes | backend/src/Entity/Notification/Notification.php +72 -55 0.6.1-backup → 1.5 View file →
@@ -6,13 +6,8 @@
6 6 */
7 7
8 8 namespace IvyForms\Entity\Notification;
9 9
10 -// phpcs:disable PSR1.Files.SideEffects
11 -if (!defined('ABSPATH')) {
12 - exit; // Exit if accessed directly
13 -}
14 -
15 10 use IvyForms\ValueObjects\Notification\Notification as NotificationValueObject;
16 11
17 12 /**
18 13 * Class Notification
@@ -26,8 +21,20 @@
26 21 */
27 22 private NotificationValueObject $notification;
28 23
29 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 + /**
30 37 * Notification constructor.
31 38 *
32 39 * @param NotificationValueObject $notification The notification object.
33 40 */
@@ -33,11 +40,28 @@
33 40 */
34 41 public function __construct(NotificationValueObject $notification)
35 42 {
36 43 $this->notification = $notification;
44 + $this->contact = new NotificationContact($notification->contact);
37 45 }
38 46
39 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 + /**
40 64 * Get the notification ID.
41 65 *
42 66 * @return int
43 67 */
@@ -76,48 +100,18 @@
76 100 $this->notification->name = $name;
77 101 }
78 102
79 103 /**
80 - * Get the notification sender.
104 + * Get the NotificationContact entity.
81 105 *
82 - * @return string
106 + * @return NotificationContact
83 107 */
84 - public function getSender(): string
108 + public function getNotificationContact(): NotificationContact
85 109 {
86 - return $this->notification->getSender();
110 + return $this->contact;
87 111 }
88 112
89 113 /**
90 - * Set the notification sender.
91 - *
92 - * @param string $sender
93 - */
94 - public function setSender(string $sender): void
95 - {
96 - $this->notification->sender = $sender;
97 - }
98 -
99 - /**
100 - * Get the notification receiver.
101 - *
102 - * @return string
103 - */
104 - public function getReceiver(): string
105 - {
106 - return $this->notification->getReceiver();
107 - }
108 -
109 - /**
110 - * Set the notification receiver.
111 - *
112 - * @param string $receiver
113 - */
114 - public function setReceiver(string $receiver): void
115 - {
116 - $this->notification->receiver = $receiver;
117 - }
118 -
119 - /**
120 114 * Get the notification status.
121 115 *
122 116 * @return bool
123 117 */
@@ -176,23 +170,43 @@
176 170 $this->notification->message = $message;
177 171 }
178 172
179 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 + /**
180 194 * Get the smart logic status.
181 195 *
182 - * @return bool
196 + * @return array<string, mixed>
183 197 */
184 - public function isSmartLogic(): bool
198 + public function getSmartLogic(): array
185 199 {
186 - return $this->notification->isSmartLogic();
200 + return $this->notification->getSmartLogic();
187 201 }
188 202
189 203 /**
190 204 * Set the smart logic status.
191 205 *
192 - * @param bool $smartLogic
206 + * @param array<string, mixed> $smartLogic
193 207 */
194 - public function setSmartLogic(bool $smartLogic): void
208 + public function setSmartLogic(array $smartLogic): void
195 209 {
196 210 $this->notification->smartLogic = $smartLogic;
197 211 }
198 212
@@ -222,17 +236,20 @@
222 236 * @return array<string, mixed> The notification entity as an array.
223 237 */
224 238 public function toArray(): array
225 239 {
226 - return [
227 - 'id' => $this->getId(),
228 - 'name' => $this->getName(),
229 - 'sender' => $this->getSender(),
230 - 'receiver' => $this->getReceiver(),
231 - 'enabled' => $this->isEnabled(),
232 - 'subject' => $this->getSubject(),
233 - 'message' => $this->getMessage(),
234 - 'smartLogic' => $this->isSmartLogic(),
235 - 'formId' => $this->getFormId(),
236 - ];
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 + );
237 254 }
238 255 }