| @@ -1,14 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Entity\Confirmation; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 10 | 5 | use IvyForms\ValueObjects\Confirmation\Confirmation as ConfirmationValueObject; |
| 6 | +use IvyForms\Common\Helpers\Helper; | |
| 11 | 7 | |
| 12 | 8 | /** |
| 13 | 9 | * Class Confirmation |
| 14 | 10 | * |
| @@ -95,21 +91,21 @@ | ||
| 95 | 91 | * Get the confirmation status. |
| 96 | 92 | * |
| 97 | 93 | * @return bool |
| 98 | 94 | */ |
| 99 | - public function isStatus(): bool | |
| 95 | + public function isEnabled(): bool | |
| 100 | 96 | { |
| 101 | - return $this->confirmation->isStatus(); | |
| 97 | + return $this->confirmation->isEnabled(); | |
| 102 | 98 | } |
| 103 | 99 | |
| 104 | 100 | /** |
| 105 | 101 | * Set the confirmation status. |
| 106 | 102 | * |
| 107 | - * @param bool $status | |
| 103 | + * @param bool $enabled | |
| 108 | 104 | */ |
| 109 | - public function setStatus(bool $status): void | |
| 105 | + public function setEnabled(bool $enabled): void | |
| 110 | 106 | { |
| 111 | - $this->confirmation->status = $status; | |
| 107 | + $this->confirmation->enabled = $enabled; | |
| 112 | 108 | } |
| 113 | 109 | |
| 114 | 110 | /** |
| 115 | 111 | * Get the show form flag. |
| @@ -191,8 +187,94 @@ | ||
| 191 | 187 | $this->confirmation->page = $page; |
| 192 | 188 | } |
| 193 | 189 | |
| 194 | 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 | + /** | |
| 195 | 277 | * Convert the confirmation entity to an array. |
| 196 | 278 | * |
| 197 | 279 | * @return array<string, mixed> The confirmation entity as an array. |
| 198 | 280 | */ |
| @@ -200,13 +282,19 @@ | ||
| 200 | 282 | { |
| 201 | 283 | return [ |
| 202 | 284 | 'id' => $this->getId(), |
| 203 | 285 | 'formId' => $this->getFormId(), |
| 286 | + 'name' => $this->getName(), | |
| 204 | 287 | 'type' => $this->getType(), |
| 205 | - 'status' => $this->isStatus(), | |
| 288 | + 'enabled' => $this->isEnabled(), | |
| 206 | 289 | 'showForm' => $this->isShowForm(), |
| 207 | 290 | 'message' => $this->getMessage(), |
| 208 | 291 | 'url' => $this->getUrl(), |
| 292 | + //TODO : Check if page is needed as we have pageUrl | |
| 209 | 293 | 'page' => $this->getPage(), |
| 294 | + 'pageUrl' => $this->getPageUrl(), | |
| 295 | + 'position' => $this->getPosition(), | |
| 296 | + 'isDefault' => $this->isDefault(), | |
| 297 | + 'smartLogic' => $this->getSmartLogic(), | |
| 210 | 298 | ]; |
| 211 | 299 | } |
| 212 | 300 | } |