<commit_before><?php
/**
 * SettingType.php
 *
 * @since 06/09/14
 * @author <NAME> <<EMAIL>>
 */

namespace Enhavo\Bundle\SettingBundle\Form\Type;

use Enhavo\Bundle\SettingBundle\Entity\Setting;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\AbstractType;

class SettingType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     * @var Setting $settingObject
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event)
        {
            $form = $event->getForm();
            /** @var Setting $settingObject */
            $settingObject = $event->getData();

            $form->add('name', 'text', [
                'read_only' => true,
                'mapped' => false,
                'data' => $settingObject->getLabel(),
                'translation_domain' => $settingObject->getTranslationDomain()
            ]);

            $type = $settingObject->getType();
            if ($type === Setting::SETTING_TYPE_TEXT) {
                $form->add('value', 'text', array(
                    'label' => 'setting.label.value',
                    'translation_domain' => 'EnhavoSettingBundle',
                ));
            }
            if ($type === Setting::SETTING_TYPE_BOOLEAN) {
                $form->add('value', 'enhavo_boolean', array(
                    'label' => 'setting.label.value',
                    'translation_domain' => 'EnhavoSettingBundle',
                ));
            }
            if ($type === Setting::SETTING_TYPE_FILE) {
                $form->add('file', 'enhavo_files', array(
                    'label' => 'setting.label.file',
                    'translation_domain' => 'EnhavoSettingBundle',
                    'multiple' => false
                ));
            }
            if ($type === Setting::SETTING_TYPE_FILES) {
                $form->add('files', 'enhavo_files', array(<commit_msg>fix media type and image cropper bugs<commit_after><?php
/**
 * SettingType.php
 *
 * @since 06/09/14
 * @author <NAME> <<EMAIL>>
 */

namespace Enhavo\Bundle\SettingBundle\Form\Type;

use Enhavo\Bundle\MediaBundle\Form\Type\MediaType;
use Enhavo\Bundle\SettingBundle\Entity\Setting;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\AbstractType;

class SettingType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     * @var Setting $settingObject
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event)
        {
            $form = $event->getForm();
            /** @var Setting $settingObject */
            $settingObject = $event->getData();

            $form->add('name', 'text', [
                'read_only' => true,
                'mapped' => false,
                'data' => $settingObject->getLabel(),
                'translation_domain' => $settingObject->getTranslationDomain()
            ]);

            $type = $settingObject->getType();
            if ($type === Setting::SETTING_TYPE_TEXT) {
                $form->add('value', 'text', array(
                    'label' => 'setting.label.value',
                    'translation_domain' => 'EnhavoSettingBundle',
                ));
            }
            if ($type === Setting::SETTING_TYPE_BOOLEAN) {
                $form->add('value', 'enhavo_boolean', array(
                    'label' => 'setting.label.value',
                    'translation_domain' => 'EnhavoSettingBundle',
                ));
            }
            if ($type === Setting::SETTING_TYPE_FILE) {
                $form->add('file', MediaType::class, array(
                    'label' => 'setting.label.file',
                    'translation_domain' => 'EnhavoSettingBundle',
                    'multiple' => false
                ));
            }
            if ($type === Setting::SETTING_TYPE_FILES) {
                $form->add('files', MediaType::class, array(
{'fraction_non_alphanumeric': 0.13852035079829098, 'fraction_numerical': 0.0026984483921744995, 'mean_word_length': 2.0382513661202184, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 53, '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': '324539', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1184, 'n_words': 209}