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 / Confirmation / Confirmation.php

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

301 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Entity\Confirmation;
4
5 use IvyForms\ValueObjects\Confirmation\Confirmation as ConfirmationValueObject;
6 use IvyForms\Common\Helpers\Helper;
7
8 /**
9 * Class Confirmation
10 *
11 * @package IvyForms\Entity\Confirmation
12 */
13 class Confirmation
14 {
15 /**
16 * @var ConfirmationValueObject
17 */
18 private ConfirmationValueObject $confirmation;
19
20 /**
21 * Confirmation constructor.
22 *
23 * @param ConfirmationValueObject $confirmation The confirmation object.
24 */
25 public function __construct(ConfirmationValueObject $confirmation)
26 {
27 $this->confirmation = $confirmation;
28 }
29
30 /**
31 * Get the confirmation ID.
32 *
33 * @return int
34 */
35 public function getId(): int
36 {
37 return $this->confirmation->getId();
38 }
39
40 /**
41 * Set the confirmation ID.
42 *
43 * @param int $id
44 */
45 public function setId(int $id): void
46 {
47 $this->confirmation->id = $id;
48 }
49
50 /**
51 * Get the form ID.
52 *
53 * @return int
54 */
55 public function getFormId(): int
56 {
57 return $this->confirmation->getFormId();
58 }
59
60 /**
61 * Set the form ID.
62 *
63 * @param int $formId
64 */
65 public function setFormId(int $formId): void
66 {
67 $this->confirmation->formId = $formId;
68 }
69
70 /**
71 * Get the confirmation type.
72 *
73 * @return string
74 */
75 public function getType(): string
76 {
77 return $this->confirmation->getType();
78 }
79
80 /**
81 * Set the confirmation type.
82 *
83 * @param string $type
84 */
85 public function setType(string $type): void
86 {
87 $this->confirmation->type = $type;
88 }
89
90 /**
91 * Get the confirmation status.
92 *
93 * @return bool
94 */
95 public function isEnabled(): bool
96 {
97 return $this->confirmation->isEnabled();
98 }
99
100 /**
101 * Set the confirmation status.
102 *
103 * @param bool $enabled
104 */
105 public function setEnabled(bool $enabled): void
106 {
107 $this->confirmation->enabled = $enabled;
108 }
109
110 /**
111 * Get the show form flag.
112 *
113 * @return bool
114 */
115 public function isShowForm(): bool
116 {
117 return $this->confirmation->isShowForm();
118 }
119
120 /**
121 * Set the show form flag.
122 *
123 * @param bool $showForm
124 */
125 public function setShowForm(bool $showForm): void
126 {
127 $this->confirmation->showForm = $showForm;
128 }
129
130 /**
131 * Get the confirmation message.
132 *
133 * @return string
134 */
135 public function getMessage(): string
136 {
137 return $this->confirmation->getMessage();
138 }
139
140 /**
141 * Set the confirmation message.
142 *
143 * @param string $message
144 */
145 public function setMessage(string $message): void
146 {
147 $this->confirmation->message = $message;
148 }
149
150 /**
151 * Get the confirmation URL.
152 *
153 * @return string
154 */
155 public function getUrl(): string
156 {
157 return $this->confirmation->getUrl();
158 }
159
160 /**
161 * Set the confirmation URL.
162 *
163 * @param string $url
164 */
165 public function setUrl(string $url): void
166 {
167 $this->confirmation->url = $url;
168 }
169
170 /**
171 * Get the confirmation page.
172 *
173 * @return string
174 */
175 public function getPage(): string
176 {
177 return $this->confirmation->getPage();
178 }
179
180 /**
181 * Set the confirmation page.
182 *
183 * @param string $page
184 */
185 public function setPage(string $page): void
186 {
187 $this->confirmation->page = $page;
188 }
189
190 /**
191 * Get the confirmation name.
192 *
193 * @return string
194 */
195 public function getName(): string
196 {
197 return $this->confirmation->getName();
198 }
199
200 /**
201 * Set the confirmation name.
202 *
203 * @param string $name
204 */
205 public function setName(string $name): void
206 {
207 $this->confirmation->name = $name;
208 }
209
210 /**
211 * Get the confirmation list position.
212 *
213 * @return int
214 */
215 public function getPosition(): int
216 {
217 return $this->confirmation->getPosition();
218 }
219
220 /**
221 * Set the confirmation list position.
222 *
223 * @param int $position
224 */
225 public function setPosition(int $position): void
226 {
227 $this->confirmation->position = $position;
228 }
229
230 /**
231 * Whether this confirmation is the default for the form.
232 *
233 * @return bool
234 */
235 public function isDefault(): bool
236 {
237 return $this->confirmation->isDefault();
238 }
239
240 /**
241 * Set whether this confirmation is the default for the form.
242 *
243 * @param bool $isDefault
244 */
245 public function setIsDefault(bool $isDefault): void
246 {
247 $this->confirmation->isDefault = $isDefault;
248 }
249
250 /**
251 * @return array<string, mixed>
252 */
253 public function getSmartLogic(): array
254 {
255 return $this->confirmation->getSmartLogic();
256 }
257
258 /**
259 * @param array<string, mixed> $smartLogic
260 */
261 public function setSmartLogic(array $smartLogic): void
262 {
263 $this->confirmation->smartLogic = $smartLogic;
264 }
265
266 /**
267 * Get the page URL converted from page ID.
268 *
269 * @return string The page URL, empty string if page is not set or not found.
270 */
271 public function getPageUrl(): string
272 {
273 return Helper::getPageUrlFromId($this->getPage());
274 }
275
276 /**
277 * Convert the confirmation entity to an array.
278 *
279 * @return array<string, mixed> The confirmation entity as an array.
280 */
281 public function toArray(): array
282 {
283 return [
284 'id' => $this->getId(),
285 'formId' => $this->getFormId(),
286 'name' => $this->getName(),
287 'type' => $this->getType(),
288 'enabled' => $this->isEnabled(),
289 'showForm' => $this->isShowForm(),
290 'message' => $this->getMessage(),
291 'url' => $this->getUrl(),
292 //TODO : Check if page is needed as we have pageUrl
293 'page' => $this->getPage(),
294 'pageUrl' => $this->getPageUrl(),
295 'position' => $this->getPosition(),
296 'isDefault' => $this->isDefault(),
297 'smartLogic' => $this->getSmartLogic(),
298 ];
299 }
300 }
301