<commit_before><?php

namespace Oro\Bundle\OrganizationBundle\Form\Type;

use Doctrine\ORM\EntityManager;
use Oro\Bundle\FormBundle\Form\DataTransformer\EntitiesToIdsTransformer;
use Oro\Bundle\FormBundle\Form\Type\OroJquerySelect2HiddenType;
use Oro\Bundle\OrganizationBundle\Entity\Manager\BusinessUnitManager;
use Oro\Bundle\OrganizationBundle\Form\Transformer\BusinessUnitTreeTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 * Select business unit with autocomplete form type.
 */
class BusinessUnitSelectAutocomplete extends AbstractType
{
    const NAME = 'oro_type_business_unit_select_autocomplete';

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return self::NAME;
    }

    /** @var EntityManager */
    protected $entityManager;

    /** @var BusinessUnitManager */
    protected $businessUnitManager;

    /** @var string */
    protected $entityClass;

    /**
     * BusinessUnitSelectAutocomplete constructor.
     *
     * @param EntityManager $entityManager
     * @param $entityClass
     * @param BusinessUnitManager $businessUnitManager
     */
    public function __construct(
        EntityManager $entityManager,
        $entityClass,
        BusinessUnitManager $businessUnitManager
    ) {
        $this->entityManager = $entityManager;
        $this->entityClass = $entityClass;
        $this->businessUnitManager = $businessUnitManager;
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if (isset($options['configs']['multiple']) &&  $options['configs']['multiple'] === true) {
            $builder->addModelTransformer(
                new EntitiesToIdsTransformer($this->entityManager, $this->entityClass)
            );
        } else {
            $builder->resetModelTransformers();
            $builder->addModelTransformer(
                new BusinessUnitTreeTransformer($this->businessUnitManager)
            );
        }
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'configs'            => [
                    'multiple'    => true,
                    'width'       => '400px',
                    'component'   => 'tree-autocomplete',
                    'placeholder' => 'oro.dashboard.form.choose_business_unit',
                    'allowClear'  => true,
                    'entity_id'   => null
                ]
            ]
        );
    }

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return OroJquerySelect2HiddenType::class;
    }<commit_msg>BAP-18027: IOS/IPAD Pro/Request for quote - update styles for Request for quote - remove hardcode with for select2<commit_after><?php

namespace Oro\Bundle\OrganizationBundle\Form\Type;

use Doctrine\ORM\EntityManager;
use Oro\Bundle\FormBundle\Form\DataTransformer\EntitiesToIdsTransformer;
use Oro\Bundle\FormBundle\Form\Type\OroJquerySelect2HiddenType;
use Oro\Bundle\OrganizationBundle\Entity\Manager\BusinessUnitManager;
use Oro\Bundle\OrganizationBundle\Form\Transformer\BusinessUnitTreeTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 * Select business unit with autocomplete form type.
 */
class BusinessUnitSelectAutocomplete extends AbstractType
{
    const NAME = 'oro_type_business_unit_select_autocomplete';

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return self::NAME;
    }

    /** @var EntityManager */
    protected $entityManager;

    /** @var BusinessUnitManager */
    protected $businessUnitManager;

    /** @var string */
    protected $entityClass;

    /**
     * BusinessUnitSelectAutocomplete constructor.
     *
     * @param EntityManager $entityManager
     * @param $entityClass
     * @param BusinessUnitManager $businessUnitManager
     */
    public function __construct(
        EntityManager $entityManager,
        $entityClass,
        BusinessUnitManager $businessUnitManager
    ) {
        $this->entityManager = $entityManager;
        $this->entityClass = $entityClass;
        $this->businessUnitManager = $businessUnitManager;
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if (isset($options['configs']['multiple']) &&  $options['configs']['multiple'] === true) {
            $builder->addModelTransformer(
                new EntitiesToIdsTransformer($this->entityManager, $this->entityClass)
            );
        } else {
            $builder->resetModelTransformers();
            $builder->addModelTransformer(
                new BusinessUnitTreeTransformer($this->businessUnitManager)
            );
        }
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'configs'            => [
                    'multiple'    => true,
                    'component'   => 'tree-autocomplete',
                    'placeholder' => 'oro.dashboard.form.choose_business_unit',
                    'allowClear'  => true,
                    'entity_id'   => null
                ]
            ]
        );
    }

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return OroJquerySelect2HiddenType::class;
    }
{'fraction_non_alphanumeric': 0.10836132225561251, 'fraction_numerical': 0.002298037829238112, 'mean_word_length': 2.375894988066826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '1568577', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1480, 'n_words': 253}