PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
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 0.9, at backend/src/Entity/Confirmation/Confirmation.php

226 lines 4.5 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 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\ValueObjects\Confirmation\Confirmation as ConfirmationValueObject;
11 use IvyForms\Common\Helpers\Helper;
12
13 /**
14 * Class Confirmation
15 *
16 * @package IvyForms\Entity\Confirmation
17 */
18 class Confirmation
19 {
20 /**
21 * @var ConfirmationValueObject
22 */
23 private ConfirmationValueObject $confirmation;
24
25 /**
26 * Confirmation constructor.
27 *
28 * @param ConfirmationValueObject $confirmation The confirmation object.
29 */
30 public function __construct(ConfirmationValueObject $confirmation)
31 {
32 $this->confirmation = $confirmation;
33 }
34
35 /**
36 * Get the confirmation ID.
37 *
38 * @return int
39 */
40 public function getId(): int
41 {
42 return $this->confirmation->getId();
43 }
44
45 /**
46 * Set the confirmation ID.
47 *
48 * @param int $id
49 */
50 public function setId(int $id): void
51 {
52 $this->confirmation->id = $id;
53 }
54
55 /**
56 * Get the form ID.
57 *
58 * @return int
59 */
60 public function getFormId(): int
61 {
62 return $this->confirmation->getFormId();
63 }
64
65 /**
66 * Set the form ID.
67 *
68 * @param int $formId
69 */
70 public function setFormId(int $formId): void
71 {
72 $this->confirmation->formId = $formId;
73 }
74
75 /**
76 * Get the confirmation type.
77 *
78 * @return string
79 */
80 public function getType(): string
81 {
82 return $this->confirmation->getType();
83 }
84
85 /**
86 * Set the confirmation type.
87 *
88 * @param string $type
89 */
90 public function setType(string $type): void
91 {
92 $this->confirmation->type = $type;
93 }
94
95 /**
96 * Get the confirmation status.
97 *
98 * @return bool
99 */
100 public function isEnabled(): bool
101 {
102 return $this->confirmation->isEnabled();
103 }
104
105 /**
106 * Set the confirmation status.
107 *
108 * @param bool $enabled
109 */
110 public function setEnabled(bool $enabled): void
111 {
112 $this->confirmation->enabled = $enabled;
113 }
114
115 /**
116 * Get the show form flag.
117 *
118 * @return bool
119 */
120 public function isShowForm(): bool
121 {
122 return $this->confirmation->isShowForm();
123 }
124
125 /**
126 * Set the show form flag.
127 *
128 * @param bool $showForm
129 */
130 public function setShowForm(bool $showForm): void
131 {
132 $this->confirmation->showForm = $showForm;
133 }
134
135 /**
136 * Get the confirmation message.
137 *
138 * @return string
139 */
140 public function getMessage(): string
141 {
142 return $this->confirmation->getMessage();
143 }
144
145 /**
146 * Set the confirmation message.
147 *
148 * @param string $message
149 */
150 public function setMessage(string $message): void
151 {
152 $this->confirmation->message = $message;
153 }
154
155 /**
156 * Get the confirmation URL.
157 *
158 * @return string
159 */
160 public function getUrl(): string
161 {
162 return $this->confirmation->getUrl();
163 }
164
165 /**
166 * Set the confirmation URL.
167 *
168 * @param string $url
169 */
170 public function setUrl(string $url): void
171 {
172 $this->confirmation->url = $url;
173 }
174
175 /**
176 * Get the confirmation page.
177 *
178 * @return string
179 */
180 public function getPage(): string
181 {
182 return $this->confirmation->getPage();
183 }
184
185 /**
186 * Set the confirmation page.
187 *
188 * @param string $page
189 */
190 public function setPage(string $page): void
191 {
192 $this->confirmation->page = $page;
193 }
194
195 /**
196 * Get the page URL converted from page ID.
197 *
198 * @return string The page URL, empty string if page is not set or not found.
199 */
200 public function getPageUrl(): string
201 {
202 return Helper::getPageUrlFromId($this->getPage());
203 }
204
205 /**
206 * Convert the confirmation entity to an array.
207 *
208 * @return array<string, mixed> The confirmation entity as an array.
209 */
210 public function toArray(): array
211 {
212 return [
213 'id' => $this->getId(),
214 'formId' => $this->getFormId(),
215 'type' => $this->getType(),
216 'enabled' => $this->isEnabled(),
217 'showForm' => $this->isShowForm(),
218 'message' => $this->getMessage(),
219 'url' => $this->getUrl(),
220 //TODO : Check if page is needed as we have pageUrl
221 'page' => $this->getPage(),
222 'pageUrl' => $this->getPageUrl(),
223 ];
224 }
225 }
226