← All changes
|
backend/src/Services/Confirmation/ConfirmationService.php
+352
-43
0.4
→
1.5.1
View file →
| @@ -1,30 +1,43 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Services\Confirmation; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 5 | +use IvyForms\Common\Exceptions\ForbiddenException; | |
| 6 | +use IvyForms\Common\Exceptions\InvalidArgumentException; | |
| 10 | 7 | use IvyForms\Common\Exceptions\NotFoundException; |
| 11 | -use IvyForms\Common\Exceptions\InvalidArgumentException; | |
| 12 | 8 | use IvyForms\Common\Exceptions\QueryExecutionException; |
| 9 | +use IvyForms\Common\Sanitizer\HtmlSanitizer; | |
| 13 | 10 | use IvyForms\Entity\Confirmation\Confirmation; |
| 14 | 11 | use IvyForms\Factory\Confirmation\ConfirmationFactory; |
| 15 | 12 | use IvyForms\Repository\Confirmation\ConfirmationRepositoryInterface; |
| 13 | +use IvyForms\Services\Media\ImageService; | |
| 16 | 14 | use IvyForms\Services\Placeholder\PlaceholderService; |
| 17 | 15 | use IvyForms\Services\Translations\BackendStrings; |
| 18 | 16 | |
| 17 | +/** | |
| 18 | + * @SuppressWarnings(PHPMD.TooManyPublicMethods) | |
| 19 | + */ | |
| 19 | 20 | class ConfirmationService |
| 20 | 21 | { |
| 21 | 22 | private ConfirmationRepositoryInterface $confirmationRepository; |
| 23 | + private ImageService $imageService; | |
| 24 | + private ConfirmationAccessPolicy $accessPolicy; | |
| 25 | + private ConfirmationResolver $confirmationResolver; | |
| 26 | + private ConfirmationOrderService $confirmationOrderService; | |
| 22 | 27 | |
| 23 | - // Constructor injection for the ConfirmationRepository via PHP-DI | |
| 24 | - public function __construct(ConfirmationRepositoryInterface $confirmationRepository) | |
| 25 | - { | |
| 28 | + public function __construct( | |
| 29 | + ConfirmationRepositoryInterface $confirmationRepository, | |
| 30 | + ImageService $imageService, | |
| 31 | + ConfirmationAccessPolicy $accessPolicy, | |
| 32 | + ConfirmationResolver $confirmationResolver, | |
| 33 | + ConfirmationOrderService $confirmationOrderService | |
| 34 | + ) { | |
| 26 | 35 | $this->confirmationRepository = $confirmationRepository; |
| 36 | + $this->imageService = $imageService; | |
| 37 | + $this->accessPolicy = $accessPolicy; | |
| 38 | + $this->confirmationResolver = $confirmationResolver; | |
| 39 | + $this->confirmationOrderService = $confirmationOrderService; | |
| 27 | 40 | } |
| 28 | 41 | |
| 29 | 42 | /** |
| 30 | 43 | * Create a new confirmation. |
| @@ -34,9 +47,19 @@ | ||
| 34 | 47 | * @return int Confirmation ID |
| 35 | 48 | */ |
| 36 | 49 | public function createConfirmation(Confirmation $confirmationData): int |
| 37 | 50 | { |
| 38 | - // Create confirmation via repository and return new confirmation ID | |
| 51 | + $formId = $confirmationData->getFormId(); | |
| 52 | + $this->accessPolicy->assertCanAdd($formId); | |
| 53 | + | |
| 54 | + if ($confirmationData->getPosition() === 0 && $this->confirmationRepository->countByFormId($formId) === 0) { | |
| 55 | + $confirmationData->setIsDefault(true); | |
| 56 | + } elseif ($confirmationData->getPosition() === 0) { | |
| 57 | + $confirmationData->setPosition($this->confirmationRepository->getNextPosition($formId)); | |
| 58 | + } | |
| 59 | + | |
| 60 | + $this->processMessageImages($confirmationData); | |
| 61 | + | |
| 39 | 62 | return $this->confirmationRepository->add($confirmationData); |
| 40 | 63 | } |
| 41 | 64 | |
| 42 | 65 | /** |
| @@ -48,8 +71,20 @@ | ||
| 48 | 71 | * @return bool |
| 49 | 72 | */ |
| 50 | 73 | public function updateConfirmation(int $confirmationId, Confirmation $confirmationData): bool |
| 51 | 74 | { |
| 75 | + $existing = $this->getConfirmationById($confirmationId); | |
| 76 | + // Always authorize and persist against the stored owner — never trust client formId. | |
| 77 | + $formId = $existing->getFormId(); | |
| 78 | + $confirmationData->setFormId($formId); | |
| 79 | + | |
| 80 | + $this->accessPolicy->assertCanManage($confirmationId, $formId, 'edit'); | |
| 81 | + | |
| 82 | + $confirmationData->setPosition($existing->getPosition()); | |
| 83 | + $confirmationData->setIsDefault($existing->isDefault()); | |
| 84 | + | |
| 85 | + $this->processMessageImages($confirmationData); | |
| 86 | + | |
| 52 | 87 | return $this->confirmationRepository->update($confirmationId, $confirmationData); |
| 53 | 88 | } |
| 54 | 89 | |
| 55 | 90 | /** |
| @@ -56,17 +91,19 @@ | ||
| 56 | 91 | * Get confirmations by form ID. |
| 57 | 92 | * |
| 58 | 93 | * @param int $id |
| 59 | 94 | * |
| 60 | - * @return mixed[]|null | |
| 95 | + * @return array<Confirmation> | |
| 61 | 96 | * |
| 62 | 97 | * @throws NotFoundException If no confirmations are found |
| 63 | 98 | */ |
| 64 | - public function getConfirmationsById(int $id): ?array | |
| 99 | + public function getConfirmationsById(int $id): array | |
| 65 | 100 | { |
| 101 | + $this->ensureDefaultConfirmationExists($id); | |
| 102 | + | |
| 66 | 103 | $confirmation = $this->confirmationRepository->getAllById($id); |
| 67 | 104 | |
| 68 | - if (!$confirmation) { | |
| 105 | + if (empty($confirmation)) { | |
| 69 | 106 | throw new NotFoundException( |
| 70 | 107 | BackendStrings::getExceptionStrings()['confirmation_not_found'] |
| 71 | 108 | ); |
| 72 | 109 | } |
| @@ -72,11 +109,26 @@ | ||
| 72 | 109 | } |
| 73 | 110 | |
| 74 | 111 | return $confirmation; |
| 75 | 112 | } |
| 113 | + | |
| 76 | 114 | /** |
| 77 | - * Get a specific form by its ID. | |
| 115 | + * Ensure a form has at least one default confirmation. | |
| 78 | 116 | * |
| 117 | + * @param int $formId | |
| 118 | + * @return int Default confirmation ID | |
| 119 | + */ | |
| 120 | + public function ensureDefaultConfirmationExists(int $formId): int | |
| 121 | + { | |
| 122 | + return $this->accessPolicy->ensureDefaultExists( | |
| 123 | + $formId, | |
| 124 | + fn (int $id): int => $this->createDefaultConfirmationForForm($id) | |
| 125 | + ); | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * Get a specific confirmation by its ID. | |
| 130 | + * | |
| 79 | 131 | * @param int $id |
| 80 | 132 | * |
| 81 | 133 | * @return object ConfirmationEntity |
| 82 | 134 | * |
| @@ -95,8 +147,41 @@ | ||
| 95 | 147 | return $confirmation; |
| 96 | 148 | } |
| 97 | 149 | |
| 98 | 150 | /** |
| 151 | + * Delete a single confirmation. | |
| 152 | + * | |
| 153 | + * @param int $confirmationId | |
| 154 | + * | |
| 155 | + * @return void | |
| 156 | + * @throws InvalidArgumentException | |
| 157 | + * @throws NotFoundException | |
| 158 | + */ | |
| 159 | + public function deleteConfirmation(int $confirmationId): void | |
| 160 | + { | |
| 161 | + $confirmation = $this->getConfirmationById($confirmationId); | |
| 162 | + $formId = $confirmation->getFormId(); | |
| 163 | + | |
| 164 | + $this->accessPolicy->assertCanManage($confirmationId, $formId, 'delete'); | |
| 165 | + | |
| 166 | + $count = $this->confirmationRepository->countByFormId($formId); | |
| 167 | + | |
| 168 | + if ($count <= 1) { | |
| 169 | + throw new InvalidArgumentException( | |
| 170 | + BackendStrings::getSettingsFormBuilderStrings()['cannot_delete_last_confirmation'] | |
| 171 | + ); | |
| 172 | + } | |
| 173 | + | |
| 174 | + $this->confirmationRepository->delete($confirmationId); | |
| 175 | + | |
| 176 | + $remaining = $this->confirmationRepository->getAllById($formId); | |
| 177 | + if (!empty($remaining)) { | |
| 178 | + $orderedIds = array_map(static fn ($item) => $item->getId(), $remaining); | |
| 179 | + $this->confirmationOrderService->applyOrder($formId, $orderedIds); | |
| 180 | + } | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 99 | 184 | * Delete confirmations by multiple form IDs. |
| 100 | 185 | * |
| 101 | 186 | * @param array<int> $formIds |
| 102 | 187 | * @return int Number of deleted confirmations |
| @@ -113,8 +198,89 @@ | ||
| 113 | 198 | return $this->confirmationRepository->deleteManyByForeignKeyValues($formIds); |
| 114 | 199 | } |
| 115 | 200 | |
| 116 | 201 | /** |
| 202 | + * Duplicate a single confirmation. | |
| 203 | + * | |
| 204 | + * @param int $confirmationId | |
| 205 | + * | |
| 206 | + * @return int New confirmation ID | |
| 207 | + * @throws ForbiddenException | |
| 208 | + * @throws NotFoundException | |
| 209 | + * @throws QueryExecutionException | |
| 210 | + */ | |
| 211 | + public function duplicateConfirmation(int $confirmationId): int | |
| 212 | + { | |
| 213 | + $original = $this->getConfirmationById($confirmationId); | |
| 214 | + $formId = $original->getFormId(); | |
| 215 | + | |
| 216 | + $this->accessPolicy->assertCanManage($confirmationId, $formId, 'duplicate'); | |
| 217 | + $this->accessPolicy->assertCanAdd($formId); | |
| 218 | + | |
| 219 | + $newData = $original->toArray(); | |
| 220 | + unset($newData['id'], $newData['pageUrl']); | |
| 221 | + $copyLabel = BackendStrings::getNewFormStrings()['copy_label']; | |
| 222 | + $newData['name'] = $newData['name'] . $copyLabel; | |
| 223 | + $newData['position'] = $this->confirmationRepository->getNextPosition($formId); | |
| 224 | + $newData['isDefault'] = false; | |
| 225 | + $newData['enabled'] = false; | |
| 226 | + | |
| 227 | + $newConfirmation = ConfirmationFactory::create($newData); | |
| 228 | + $newId = $this->createConfirmation($newConfirmation); | |
| 229 | + | |
| 230 | + if (!$newId) { | |
| 231 | + throw new QueryExecutionException( | |
| 232 | + BackendStrings::getSettingsFormBuilderStrings()['failed_to_duplicate_confirmation'] | |
| 233 | + ); | |
| 234 | + } | |
| 235 | + | |
| 236 | + $newConfirmation->setId($newId); | |
| 237 | + return $newId; | |
| 238 | + } | |
| 239 | + | |
| 240 | + /** | |
| 241 | + * Search confirmations with pagination and sorting. | |
| 242 | + * | |
| 243 | + * @param array<string, mixed> $params | |
| 244 | + * | |
| 245 | + * @return array<string, mixed> | |
| 246 | + */ | |
| 247 | + public function searchConfirmations(array $params): array | |
| 248 | + { | |
| 249 | + $result = $this->confirmationRepository->search($params); | |
| 250 | + | |
| 251 | + $formId = isset($params['filters']['formId']) ? (int) $params['filters']['formId'] : 0; | |
| 252 | + if ($formId > 0 && ($result['meta']['total'] ?? 0) === 0) { | |
| 253 | + $this->ensureDefaultConfirmationExists($formId); | |
| 254 | + | |
| 255 | + return $this->confirmationRepository->search($params); | |
| 256 | + } | |
| 257 | + | |
| 258 | + return $result; | |
| 259 | + } | |
| 260 | + | |
| 261 | + /** | |
| 262 | + * Reorder confirmations for a form. | |
| 263 | + * | |
| 264 | + * @param int $formId | |
| 265 | + * @param array<int, int> $orderedIds | |
| 266 | + * | |
| 267 | + * @return void | |
| 268 | + * @throws ForbiddenException | |
| 269 | + */ | |
| 270 | + public function reorderConfirmations(int $formId, array $orderedIds): void | |
| 271 | + { | |
| 272 | + if (!apply_filters('ivyforms/can_create_multiple_confirmations', false, $formId)) { | |
| 273 | + throw new ForbiddenException( | |
| 274 | + BackendStrings::getSettingsFormBuilderStrings()['multiple_confirmations_pro_required'] | |
| 275 | + ); | |
| 276 | + } | |
| 277 | + | |
| 278 | + $this->confirmationOrderService->validateReorderIds($formId, $orderedIds); | |
| 279 | + $this->confirmationOrderService->applyOrder($formId, $orderedIds); | |
| 280 | + } | |
| 281 | + | |
| 282 | + /** | |
| 117 | 283 | * Duplicate confirmations from one form to another. |
| 118 | 284 | * |
| 119 | 285 | * @param int $originalFormId |
| 120 | 286 | * @param int $newFormId |
| @@ -124,14 +290,18 @@ | ||
| 124 | 290 | */ |
| 125 | 291 | public function duplicateConfirmations(int $originalFormId, int $newFormId): void |
| 126 | 292 | { |
| 127 | 293 | $confirmations = $this->getConfirmationsById($originalFormId); |
| 128 | - foreach ($confirmations as $confirmation) { | |
| 294 | + foreach ($confirmations as $index => $confirmation) { | |
| 129 | 295 | $confirmationData = $confirmation->toArray(); |
| 130 | - unset($confirmationData['id']); | |
| 296 | + unset($confirmationData['id'], $confirmationData['pageUrl']); | |
| 131 | 297 | $confirmationData['formId'] = $newFormId; |
| 298 | + $confirmationData['position'] = $index; | |
| 299 | + $confirmationData['isDefault'] = $index === 0; | |
| 132 | 300 | |
| 133 | - $this->createConfirmation(ConfirmationFactory::create($confirmationData)); | |
| 301 | + $entity = ConfirmationFactory::create($confirmationData); | |
| 302 | + $this->processMessageImages($entity); | |
| 303 | + $this->confirmationRepository->add($entity); | |
| 134 | 304 | } |
| 135 | 305 | } |
| 136 | 306 | |
| 137 | 307 | /** |
| @@ -141,19 +311,28 @@ | ||
| 141 | 311 | * @return int Confirmation ID |
| 142 | 312 | */ |
| 143 | 313 | public function createDefaultConfirmationForForm(int $formId): int |
| 144 | 314 | { |
| 315 | + $strings = BackendStrings::getSettingsFormBuilderStrings(); | |
| 145 | 316 | $defaultConfirmation = [ |
| 146 | - 'formId' => $formId, | |
| 147 | - 'type' => 'successMessage', | |
| 148 | - 'enabled' => 1, | |
| 149 | - 'showForm' => 0, | |
| 150 | - 'message' => BackendStrings::getAllFormsStrings()['thanks_reaching'], | |
| 151 | - 'url' => '', | |
| 152 | - 'page' => '', | |
| 317 | + 'formId' => $formId, | |
| 318 | + 'name' => $strings['default_confirmation_name'], | |
| 319 | + 'type' => 'successMessage', | |
| 320 | + 'enabled' => 1, | |
| 321 | + 'showForm' => 0, | |
| 322 | + 'message' => BackendStrings::getAllFormsStrings()['thanks_reaching'], | |
| 323 | + 'url' => '', | |
| 324 | + 'page' => '', | |
| 325 | + 'position' => 0, | |
| 326 | + 'isDefault' => 1, | |
| 327 | + 'smartLogic' => [ | |
| 328 | + 'enabled' => false, | |
| 329 | + 'match' => 'any', | |
| 330 | + 'rules' => [], | |
| 331 | + ], | |
| 153 | 332 | ]; |
| 154 | 333 | $confirmation = ConfirmationFactory::create($defaultConfirmation); |
| 155 | - $confirmationId = $this->createConfirmation($confirmation); | |
| 334 | + $confirmationId = $this->confirmationRepository->add($confirmation); | |
| 156 | 335 | if (!$confirmationId) { |
| 157 | 336 | throw new QueryExecutionException( |
| 158 | 337 | BackendStrings::getSettingsFormBuilderStrings()['failed_to_create_confirmation'] |
| 159 | 338 | ); |
| @@ -162,38 +341,168 @@ | ||
| 162 | 341 | return $confirmationId; |
| 163 | 342 | } |
| 164 | 343 | |
| 165 | 344 | /** |
| 345 | + * Resolve the first active confirmation for a form (by list order). | |
| 346 | + * Used when submission data is unavailable (e.g. builder preview). | |
| 347 | + * | |
| 348 | + * @param int $formId | |
| 349 | + * @return Confirmation|null | |
| 350 | + * @throws NotFoundException | |
| 351 | + */ | |
| 352 | + public function getActiveConfirmation(int $formId): ?Confirmation | |
| 353 | + { | |
| 354 | + $confirmations = $this->getConfirmationsById($formId); | |
| 355 | + foreach ($confirmations as $confirmation) { | |
| 356 | + if ($confirmation->isEnabled()) { | |
| 357 | + return $confirmation; | |
| 358 | + } | |
| 359 | + } | |
| 360 | + | |
| 361 | + return null; | |
| 362 | + } | |
| 363 | + | |
| 364 | + /** | |
| 365 | + * Resolve which confirmation applies after submission (conditional logic + default fallback). | |
| 366 | + * | |
| 367 | + * @param int $formId | |
| 368 | + * @param array<string, mixed> $submissionData | |
| 369 | + * @param array<int, mixed> $formFields | |
| 370 | + * @return Confirmation|null | |
| 371 | + * @throws NotFoundException | |
| 372 | + */ | |
| 373 | + public function resolveActiveConfirmation( | |
| 374 | + int $formId, | |
| 375 | + array $submissionData, | |
| 376 | + array $formFields | |
| 377 | + ): ?Confirmation { | |
| 378 | + return $this->confirmationResolver->resolve( | |
| 379 | + $this->getConfirmationsById($formId), | |
| 380 | + $submissionData, | |
| 381 | + $formFields, | |
| 382 | + $formId | |
| 383 | + ); | |
| 384 | + } | |
| 385 | + | |
| 386 | + /** | |
| 387 | + * Build the public confirmation payload for a resolved confirmation. | |
| 388 | + * | |
| 389 | + * @param Confirmation $confirmation | |
| 390 | + * @param array<string, mixed> $fieldData | |
| 391 | + * @param array<string, mixed> $generalData | |
| 392 | + * @param array<string, string> $fieldLabels | |
| 393 | + * @return array<string, mixed> | |
| 394 | + */ | |
| 395 | + public function buildConfirmationResult( | |
| 396 | + Confirmation $confirmation, | |
| 397 | + array $fieldData, | |
| 398 | + array $generalData, | |
| 399 | + array $fieldLabels = [] | |
| 400 | + ): array { | |
| 401 | + $type = $confirmation->getType(); | |
| 402 | + $message = ''; | |
| 403 | + | |
| 404 | + if ($type === 'successMessage') { | |
| 405 | + $message = PlaceholderService::replacePlaceholders( | |
| 406 | + $confirmation->getMessage(), | |
| 407 | + $fieldData, | |
| 408 | + $generalData, | |
| 409 | + $fieldLabels | |
| 410 | + ); | |
| 411 | + } | |
| 412 | + | |
| 413 | + return [ | |
| 414 | + 'id' => $confirmation->getId(), | |
| 415 | + 'type' => $type, | |
| 416 | + 'message' => $message, | |
| 417 | + 'showForm' => $confirmation->isShowForm(), | |
| 418 | + 'url' => $confirmation->getUrl(), | |
| 419 | + 'pageUrl' => $confirmation->getPageUrl(), | |
| 420 | + 'isDefault' => $confirmation->isDefault(), | |
| 421 | + ]; | |
| 422 | + } | |
| 423 | + | |
| 424 | + /** | |
| 166 | 425 | * Process confirmations for the form. |
| 167 | 426 | * |
| 168 | 427 | * @param int $formId |
| 428 | + * @param array<string, mixed> $submissionData | |
| 429 | + * @param array<int, mixed> $formFields | |
| 169 | 430 | * @param array<string, mixed> $fieldData |
| 170 | 431 | * @param array<string, mixed> $generalData |
| 171 | 432 | * @param array<string, string> $fieldLabels |
| 172 | - * @return string | |
| 433 | + * @return array<string, mixed> | |
| 173 | 434 | * @throws NotFoundException |
| 174 | 435 | */ |
| 175 | 436 | public function processConfirmations( |
| 176 | 437 | int $formId, |
| 438 | + array $submissionData, | |
| 439 | + array $formFields, | |
| 177 | 440 | array $fieldData, |
| 178 | 441 | array $generalData, |
| 179 | 442 | array $fieldLabels = [] |
| 180 | - ): string { | |
| 181 | - $confirmations = $this->getConfirmationsById($formId); | |
| 182 | - foreach ($confirmations as $confirmation) { | |
| 183 | - if ( | |
| 184 | - !empty($confirmation) && | |
| 185 | - $confirmation->isEnabled() && | |
| 186 | - $confirmation->getType() === 'successMessage' | |
| 187 | - ) { | |
| 188 | - $confirmationMessage = $confirmation->getMessage(); | |
| 189 | - return PlaceholderService::replacePlaceholders( | |
| 190 | - $confirmationMessage, | |
| 191 | - $fieldData, | |
| 192 | - $generalData, | |
| 193 | - $fieldLabels | |
| 194 | - ); | |
| 195 | - } | |
| 443 | + ): array { | |
| 444 | + $confirmation = $this->resolveActiveConfirmation($formId, $submissionData, $formFields); | |
| 445 | + if ($confirmation === null) { | |
| 446 | + $confirmation = $this->getActiveConfirmation($formId); | |
| 196 | 447 | } |
| 197 | - return ''; | |
| 448 | + if ($confirmation === null) { | |
| 449 | + return [ | |
| 450 | + 'message' => '', | |
| 451 | + 'result' => null, | |
| 452 | + ]; | |
| 453 | + } | |
| 454 | + | |
| 455 | + $result = $this->buildConfirmationResult($confirmation, $fieldData, $generalData, $fieldLabels); | |
| 456 | + | |
| 457 | + return [ | |
| 458 | + 'message' => $result['message'] ?? '', | |
| 459 | + 'result' => $result, | |
| 460 | + ]; | |
| 461 | + } | |
| 462 | + | |
| 463 | + /** | |
| 464 | + * Sanitize confirmation message and redirect URLs for the submission API response. | |
| 465 | + * | |
| 466 | + * @param array<string, mixed> $confirmationPayload | |
| 467 | + * @return array{message: string, result: array<string, mixed>|null} | |
| 468 | + */ | |
| 469 | + public function sanitizeProcessedPayload(array $confirmationPayload): array | |
| 470 | + { | |
| 471 | + $safeConfirmationMessage = HtmlSanitizer::sanitizeEditorContent( | |
| 472 | + $confirmationPayload['message'] ?? '' | |
| 473 | + ); | |
| 474 | + $confirmationResult = $confirmationPayload['result'] ?? null; | |
| 475 | + | |
| 476 | + if (!is_array($confirmationResult) || !isset($confirmationResult['message'])) { | |
| 477 | + return [ | |
| 478 | + 'message' => $safeConfirmationMessage, | |
| 479 | + 'result' => is_array($confirmationResult) ? $confirmationResult : null, | |
| 480 | + ]; | |
| 481 | + } | |
| 482 | + | |
| 483 | + $confirmationResult['message'] = $safeConfirmationMessage; | |
| 484 | + if (!empty($confirmationResult['url'])) { | |
| 485 | + $confirmationResult['url'] = esc_url_raw((string) $confirmationResult['url']); | |
| 486 | + } | |
| 487 | + if (!empty($confirmationResult['pageUrl'])) { | |
| 488 | + $confirmationResult['pageUrl'] = esc_url_raw((string) $confirmationResult['pageUrl']); | |
| 489 | + } | |
| 490 | + | |
| 491 | + return [ | |
| 492 | + 'message' => $safeConfirmationMessage, | |
| 493 | + 'result' => $confirmationResult, | |
| 494 | + ]; | |
| 495 | + } | |
| 496 | + | |
| 497 | + private function processMessageImages(Confirmation $confirmationData): void | |
| 498 | + { | |
| 499 | + $message = $confirmationData->getMessage(); | |
| 500 | + if ($message === '') { | |
| 501 | + return; | |
| 502 | + } | |
| 503 | + | |
| 504 | + $confirmationData->setMessage( | |
| 505 | + $this->imageService->processImagesInContent($message, 'confirmation') | |
| 506 | + ); | |
| 198 | 507 | } |
| 199 | 508 | } |