<?php


namespace AutoAdmin\Bundle\Seo\Form;


use AutoAdmin\Bundle\Admin\Form\Type\AdminFormType;
use AutoAdmin\Bundle\Seo\Entity\SeoMetadata;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class SeoMetadataType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            'title',
            TextType::class,
            [
                'label' => 'seo.form.title',
                'empty_data' => '',
                'required' => false,
            ]
        );

        $builder->add(
            'title_force_generation',
            CheckboxType::class,
            [
                'label' => 'seo.form.title.force_generation',
                'required' => false,
                'mapped' => false,
            ]
        );

        $builder->add(
            'description',
            TextType::class,
            [
                'label' => 'seo.form.description',
                'empty_data' => '',
                'required' => false,
            ]
        );

        $builder->add(
            'description_force_generation',
            CheckboxType::class,
            [
                'label' => 'seo.form.description.force_generation',
                'required' => false,
                'mapped' => false,
            ]
        );

        $builder->add(
            'noIndex',
            CheckboxType::class,
            [
                'label' => 'seo.form.no_index',
                'required' => false,
            ]
        );
        $builder->add(
            'noFollow',
            CheckboxType::class,
            [
                'label' => 'seo.form.no_follow',
                'required' => false,
            ]
        );
        $builder->add(
            'hideFromSitemap',
            CheckboxType::class,
            [
                'label' => 'seo.form.hide_from_sitemap',
                'required' => false,
            ]
        );
        $builder->add(
            'canonicalOverride',
            TextType::class,
            [
                'label' => 'seo.form.canonical_override',
                'required' => false,
            ]
        );
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);

        $resolver->setDefault('data_class', SeoMetadata::class);
        $resolver->setDefault('label', false);
    }

    public function getParent(): string
    {
        return AdminFormType::class;
    }
}