<?php

namespace Opentalent\OtTemplating\XClass\Form\Finishers;

use Symfony\Component\Mime\Address;

class EmailFinisher extends \TYPO3\CMS\Form\Domain\Finishers\EmailFinisher
{
    /**
     * Get mail recipients
     *
     * @param string $listOption List option name
     * @return array
     */
    protected function getRecipients(string $listOption): array {
        if ($listOption === 'recipients') {
            $address = $this->parseOption($listOption) ?? null;

            if ($address && is_string($address)) {
                return [new Address($address, 'Contact')];
            }
        }
        return parent::getRecipients($listOption);
    }
}
