PluginProbe
The Innovative Form Builder – IvyForms / 0.3
The Innovative Form Builder – IvyForms v0.3
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 / Form / Form.php

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

283 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 /**
4 * @copyright © TMS-Plugins. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace IvyForms\Entity\Form;
9
10 // phpcs:disable PSR1.Files.SideEffects
11 if (!defined('ABSPATH')) {
12 exit; // Exit if accessed directly
13 }
14
15 use IvyForms\ValueObjects\Form\Form as FormValueObject;
16
17 /**
18 * Class Form
19 *
20 * @package IvyForms\Entity\Form
21 */
22 class Form
23 {
24 /**
25 * @var FormValueObject
26 */
27 private FormValueObject $form;
28
29 /**
30 * Form constructor.
31 *
32 * @param FormValueObject $form The form object.
33 */
34 public function __construct(FormValueObject $form)
35 {
36 $this->form = $form;
37 }
38
39 /**
40 * Get the ID of the form.
41 *
42 * @return int The form ID.
43 */
44 public function getId(): int
45 {
46 return $this->form->getId();
47 }
48
49 /**
50 * Set the ID of the form.
51 *
52 * @param int $formId The form ID to set.
53 */
54 public function setId(int $formId): void
55 {
56 $this->form->id = $formId;
57 }
58
59 /**
60 * Get the name of the form.
61 *
62 * @return string The form name.
63 */
64 public function getName(): string
65 {
66 return $this->form->getName();
67 }
68
69 /**
70 * Set the name of the form.
71 *
72 * @param string $name The form name to set.
73 */
74 public function setName(string $name): void
75 {
76 $this->form->name = $name;
77 }
78
79 /**
80 * Get the author of the form.
81 *
82 * @return string The form author.
83 */
84 public function getAuthor(): string
85 {
86 return $this->form->getAuthor();
87 }
88
89 /**
90 * Set the author of the form.
91 *
92 * @param string $author The form author to set.
93 */
94 public function setAuthor(string $author): void
95 {
96 $this->form->author = $author;
97 }
98
99 /**
100 * Get the starred status of the form.
101 *
102 * @return bool The form starred status.
103 */
104 public function isStarred(): bool
105 {
106 return $this->form->isStarred();
107 }
108
109 /**
110 * Set the starred status of the form.
111 *
112 * @param bool $starred The form starred status to set.
113 */
114 public function setStarred(bool $starred): void
115 {
116 $this->form->starred = $starred;
117 }
118
119 /**
120 * Get the published status of the form.
121 *
122 * @return bool The form published status.
123 */
124 public function isPublished(): bool
125 {
126 return $this->form->isPublished();
127 }
128
129 /**
130 * Set the published status of the form.
131 *
132 * @param bool $published The form published status to set.
133 */
134 public function setPublished(bool $published): void
135 {
136 $this->form->published = $published;
137 }
138
139 /**
140 * Get the creation date of the form.
141 *
142 * @return string The form of date creation.
143 */
144 public function getDateCreated(): string
145 {
146 return $this->form->getDateCreated();
147 }
148 /**
149 * Get the date edited of the form.
150 *
151 * @return string The form date edited.
152 */
153 public function getDateEdited(): string
154 {
155 return $this->form->getDateEdited();
156 }
157
158 /**
159 * Get the form fields.
160 *
161 * @return mixed[] The form fields.
162 */
163 public function getFields(): array
164 {
165 return $this->form->getFields();
166 }
167
168 /**
169 * Set the form fields.
170 *
171 * @param mixed[] $fields The form fields to set.
172 */
173 public function setFields(array $fields): void
174 {
175 $this->form->fields = $fields;
176 }
177
178 /**
179 * Get the form description.
180 *
181 * @return string The form description.
182 */
183 public function getDescription(): string
184 {
185 return $this->form->getDescription();
186 }
187
188 /**
189 * Set the form description.
190 *
191 * @param string $description The form description to set.
192 */
193 public function setDescription(string $description): void
194 {
195 $this->form->description = $description;
196 }
197
198 /**
199 * Get the show title of the form.
200 *
201 * @return bool The form show title status.
202 */
203 public function isTitleVisible(): bool
204 {
205 return $this->form->isTitleVisible();
206 }
207
208 /**
209 * Set the show title of the form.
210 *
211 * @param bool $showTitle The form show title to set.
212 */
213 public function setTitleVisible(bool $showTitle): void
214 {
215 $this->form->showTitle = $showTitle;
216 }
217 /**
218 * Get the show description of the form.
219 *
220 * @return bool The form show description status.
221 */
222 public function isDescriptionVisible(): bool
223 {
224 return $this->form->isDescriptionVisible();
225 }
226
227
228 /**
229 * Set the show description of the form.
230 *
231 * @param bool $description The form show title to set.
232 */
233 public function setDescriptionVisible(bool $description): void
234 {
235 $this->form->showDescription = $description;
236 }
237
238 /**
239 *
240 * Set whether to store entries or not.
241 *
242 * @param bool $storeEntries
243 * @return void
244 */
245 public function setStoreEntries(bool $storeEntries): void
246 {
247 $this->form->storeEntries = $storeEntries;
248 }
249 /**
250 *
251 * Get whether to store entries or not.
252 *
253 * @return bool
254 */
255 public function isStoreEntries(): bool
256 {
257 return $this->form->storeEntries;
258 }
259
260 /**
261 * Convert the form entity to an array.
262 *
263 * @return array<string, mixed> The form entity as an array.
264 */
265 public function toArray(): array
266 {
267 return [
268 'id' => $this->getId(),
269 'name' => $this->getName(),
270 'author' => $this->getAuthor(),
271 'starred' => $this->isStarred(),
272 'published' => $this->isPublished(),
273 'dateCreated' => $this->getDateCreated(),
274 'dateEdited' => $this->getDateEdited(),
275 'fields' => $this->getFields(),
276 'description' => $this->getDescription(),
277 'showTitle' => $this->isTitleVisible(),
278 'showDescription' => $this->isDescriptionVisible(),
279 'storeEntries' => $this->isStoreEntries(),
280 ];
281 }
282 }
283