<commit_before><?php

namespace Shopsys\ProductFeed\ZboziBundle\Form;

use Shopsys\FormTypesBundle\MultidomainType;
use Shopsys\FormTypesBundle\YesNoType;
use Shopsys\FrameworkBundle\Component\Money\Money;
use Shopsys\FrameworkBundle\Form\Constraints\MoneyRange;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Translation\TranslatorInterface;

class ZboziProductFormType extends AbstractType
{
    /**
     * @var \Symfony\Component\Translation\TranslatorInterface
     */
    private $translator;

    /**
     * @param \Symfony\Component\Translation\TranslatorInterface $translator
     */
    public function __construct(TranslatorInterface $translator)
    {
        $this->translator = $translator;
    }

    /**
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('show', MultidomainType::class, [
                'label' => $this->translator->trans('Offer in feed'),
                'entry_type' => YesNoType::class,
                'required' => false,
            ])
            ->add('cpc', MultidomainType::class, [
                'label' => $this->translator->trans('Maximum price per click'),
                'entry_type' => MoneyType::class,
                'required' => false,
                'entry_options' => [
                    'currency' => 'CZK',
                    'constraints' => [
                        new MoneyRange([
                            'min' => Money::create(1),
                            'max' => Money::create(500),
                        ]),
                    ],
                ],
            ])
            ->add('cpc_search', MultidomainType::class, [
                'label' => $this->translator->trans('Maximum price per click in offers'),
                'entry_type' => MoneyType::class,
                'required' => false,
                'entry_options' => [
                    'currency' => 'CZK',
                    'constraints' => [
                        new MoneyRange([
                            'min' => Money::create(1),
                            'max' => Money::create(500),
                        ]),
                    ],
                ],
            ])
            ->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
                // Setting default value of multidomain form "show" to true via event because of dynamic form count
                $multidomainShowForm = $event->getForm()->get('show');
                foreach ($multidomainShowForm as $showForm) {
                    /* @var $showForm \Symfony\Component\Form\FormInterface */
                    if ($showForm->getData() === null) {
                        $showForm->setData(true);
                    }
                }
            });
    }
}
<commit_msg>use TranslatorInterface from Contracts namespace<commit_after><?php

namespace Shopsys\ProductFeed\ZboziBundle\Form;

use Shopsys\FormTypesBundle\MultidomainType;
use Shopsys\FormTypesBundle\YesNoType;
use Shopsys\FrameworkBundle\Component\Money\Money;
use Shopsys\FrameworkBundle\Form\Constraints\MoneyRange;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Contracts\Translation\TranslatorInterface;

class ZboziProductFormType extends AbstractType
{
    /**
     * @var \Symfony\Contracts\Translation\TranslatorInterface
     */
    private $translator;

    /**
     * @param \Symfony\Contracts\Translation\TranslatorInterface $translator
     */
    public function __construct(TranslatorInterface $translator)
    {
        $this->translator = $translator;
    }

    /**
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('show', MultidomainType::class, [
                'label' => $this->translator->trans('Offer in feed'),
                'entry_type' => YesNoType::class,
                'required' => false,
            ])
            ->add('cpc', MultidomainType::class, [
                'label' => $this->translator->trans('Maximum price per click'),
                'entry_type' => MoneyType::class,
                'required' => false,
                'entry_options' => [
                    'currency' => 'CZK',
                    'constraints' => [
                        new MoneyRange([
                            'min' => Money::create(1),
                            'max' => Money::create(500),
                        ]),
                    ],
                ],
            ])
            ->add('cpc_search', MultidomainType::class, [
                'label' => $this->translator->trans('Maximum price per click in offers'),
                'entry_type' => MoneyType::class,
                'required' => false,
                'entry_options' => [
                    'currency' => 'CZK',
                    'constraints' => [
                        new MoneyRange([
                            'min' => Money::create(1),
                            'max' => Money::create(500),
                        ]),
                    ],
                ],
            ])
            ->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) {
                // Setting default value of multidomain form "show" to true via event because of dynamic form count
                $multidomainShowForm = $event->getForm()->get('show');
                foreach ($multidomainShowForm as $showForm) {
                    /* @var $showForm \Symfony\Component\Form\FormInterface */
                    if ($showForm->getData() === null) {
                        $showForm->setData(true);
                    }
                }
            });
    }
}

{'fraction_non_alphanumeric': 0.12150279776179057, 'fraction_numerical': 0.002557953637090328, 'mean_word_length': 1.7000431592576608, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3525262', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1592, 'n_words': 284}