<commit_before><?php

/*
 * This file is part of the Goteo Package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the README.md
 * and LICENSE files that was distributed with this source code.
 */

namespace Goteo\Util\Form\Type;

use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 *
 * This class creates overides Date to show always as the single_text option is activated
 *
 */
class TypeaheadType extends TextType
{

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setDefault('sources', ''); // Sources: 'channel', 'call', 'matcher', 'project', 'user', 'consultant'
        // $resolver->setDefault('engines', []); // Url for autocomplete
        // $resolver->setDefault('defaults', []); // Url for autocomplete
        $resolver->setDefault('row_class', '');
        $resolver->setDefault('text', ''); // If exists, the text shown instead of the value
        $resolver->setDefault('fake_id', ''); // Created automatically, the id of the typeahead input field (real data is placed in a hidden field)
        $resolver->setDefault('value_field', 'id'); // Field where to extract the Value from API calls, placed in the hidden field
        $resolver->setDefault('type','simple');
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        parent::buildView($view, $form, $options);
        if(is_array($options['attr']['class'])) $view->vars['attr']['class'] = implode(' ', $view->vars['attr']['class']);
        if(empty($view->vars['fake_id'])) $view->vars['fake_id'] = 'typeahead_' . $view->vars['id'];
        $view->vars['attr']['class'] .= 'form-control typeahead';
        $view->vars['attr']['autocomplete'] = 'off';
        $view->vars['sources'] = $options['sources'];
        $view->vars['text'] = $options['text'] ? $options['text'] : $view->vars['value'];
        $view->vars['row_class'] = $options['row_class'];
        $view->vars['value_field'] = $options['value_field'];
        $view->vars['type'] = $options['type'];
    }

    public function getName()<commit_msg>add comment to type in typeaheadtype<commit_after><?php

/*
 * This file is part of the Goteo Package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the README.md
 * and LICENSE files that was distributed with this source code.
 */

namespace Goteo\Util\Form\Type;

use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 *
 * This class creates overides Date to show always as the single_text option is activated
 *
 */
class TypeaheadType extends TextType
{

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setDefault('sources', ''); // Sources: 'channel', 'call', 'matcher', 'project', 'user', 'consultant'
        // $resolver->setDefault('engines', []); // Url for autocomplete
        // $resolver->setDefault('defaults', []); // Url for autocomplete
        $resolver->setDefault('row_class', '');
        $resolver->setDefault('text', ''); // If exists, the text shown instead of the value
        $resolver->setDefault('fake_id', ''); // Created automatically, the id of the typeahead input field (real data is placed in a hidden field)
        $resolver->setDefault('value_field', 'id'); // Field where to extract the Value from API calls, placed in the hidden field
        $resolver->setDefault('type','simple'); // Field to change between typeahead with only one input or with multiple ['simple', 'multiple']
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        parent::buildView($view, $form, $options);
        if(is_array($options['attr']['class'])) $view->vars['attr']['class'] = implode(' ', $view->vars['attr']['class']);
        if(empty($view->vars['fake_id'])) $view->vars['fake_id'] = 'typeahead_' . $view->vars['id'];
        $view->vars['attr']['class'] .= 'form-control typeahead';
        $view->vars['attr']['autocomplete'] = 'off';
        $view->vars['sources'] = $options['sources'];
        $view->vars['text'] = $options['text'] ? $options['text'] : $view->vars['value'];
        $view->vars['row_class'] = $options['row_class'];
        $view->vars['value_field'] = $options['value_field'];
        $view->vars['type'] = $options['type'];
    }

    public function getName()
{'fraction_non_alphanumeric': 0.17628607277289837, 'fraction_numerical': 0.0, 'mean_word_length': 3.621256038647343, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, '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': '1875668', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1371, 'n_words': 352}