<?php

namespace AutoAdmin\Bundle\Admin\Form\Extension;

use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AdminCheckboxExtension extends AbstractTypeExtension
{
    public static function getExtendedTypes(): iterable
    {
        return [CheckboxType::class];
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        if (!$resolver->hasDefault('required')) {
            $resolver->setDefault('required', false);
        }

        $resolver->setDefault('label_attr', [
            'class' => 'switch-custom',
        ]);

        parent::configureOptions($resolver);
    }
}
