62 lines
2.2 KiB
PHP
62 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Form\Service;
|
|
|
|
use App\Form\Model\BookingDtoInterface;
|
|
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
|
|
|
/**
|
|
* Handles processing of the remarksRoom field for booking participants.
|
|
*
|
|
* This handler manages room-specific remarks for participants in the booking
|
|
* creation process. It processes the remarksRoom field from form submissions
|
|
* and updates the participant DTO with the provided remarks.
|
|
*
|
|
* Key responsibilities:
|
|
* - Processes room remarks text input
|
|
* - Handles empty text normalization (empty string → null)
|
|
* - Updates participant DTO with normalized remarks
|
|
*
|
|
* Dependencies: None (this is a simple text field)
|
|
*/
|
|
class ParticipantRemarksRoomFieldHandler extends AbstractParticipantFieldHandler
|
|
{
|
|
/**
|
|
* Returns the form field name this handler processes.
|
|
*
|
|
* @return string The field name 'remarksRoom'
|
|
*/
|
|
public function getFieldName(): string
|
|
{
|
|
return 'remarksRoom';
|
|
}
|
|
|
|
/**
|
|
* Processes the remarksRoom field for a specific participant.
|
|
*
|
|
* This method extracts room remarks from submitted form data and
|
|
* updates the corresponding participant in the booking DTO. It handles
|
|
* the normalization of empty strings to null values.
|
|
*
|
|
* @param array<string, mixed> $submittedData The submitted participant form data
|
|
* @param BookingDtoInterface $bookingDto The booking DTO to update (create or edit)
|
|
* @param int $participantIndex The index of the participant being processed
|
|
*/
|
|
public function processField(array $submittedData, BookingDtoInterface $bookingDto, int $participantIndex): void
|
|
{
|
|
// Safely get the participant object, returning early if not found
|
|
$participant = $this->getParticipant($bookingDto, $participantIndex);
|
|
if (null === $participant) {
|
|
return;
|
|
}
|
|
|
|
// Extract the room remarks from form data
|
|
$remarksRoom = $this->getFieldValue($submittedData, $this->getFieldName());
|
|
|
|
// Normalize empty string to null and update participant
|
|
$participant->remarksRoom = $this->normalizeEmptyValue($remarksRoom);
|
|
}
|
|
}
|