<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\AdminBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class BrevoSmsConfigType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('BREVO_API_KEY', PasswordType::class, [
                'label' => 'Brevo API-Key',
                'help' => 'Der API-Key von Brevo für den SMS-Versand.',
                'required' => false,
                'mapped' => true,
                'always_empty' => false,
                'attr' => [
                    'placeholder' => $options['has_api_key'] ? '••••••••••••••••' : '',
                    'readonly' => $options['readonly_api_key'],
                ],
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'has_api_key' => false,
            'readonly_api_key' => false,
        ]);
    }
}
