<commit_before><?php

namespace JBen87\ParsleyBundle\Form\Extension;

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

/**
 * @author <NAME> <<EMAIL>>
 */
class ParsleyTypeExtension extends AbstractTypeExtension
{
    /**
     * @var string
     */
    protected $triggerEvent;

    /**
     * @param string $triggerEvent
     */
    public function __construct($triggerEvent)
    {
        $this->triggerEvent = $triggerEvent;
    }

    /**
     * {@inheritdoc}
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setOptional(['parsley_trigger_event']);
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $triggerEvent = $this->triggerEvent;

        if (isset($options['parsley_trigger_event'])) {
            $triggerEvent = $options['parsley_trigger_event'];
        }

        $view->vars['attr']['data-parsley-trigger'] = $triggerEvent;
    }

    /**
     * {@inheritdoc}
     */
    public function getExtendedType()
    {
        return 'form';
    }
}
<commit_msg>Handle compatibility for symfony <= 2.5<commit_after><?php

namespace JBen87\ParsleyBundle\Form\Extension;

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

/**
 * @author <NAME> <<EMAIL>>
 */
class ParsleyTypeExtension extends AbstractTypeExtension
{
    /**
     * @var string
     */
    protected $triggerEvent;

    /**
     * @param string $triggerEvent
     */
    public function __construct($triggerEvent)
    {
        $this->triggerEvent = $triggerEvent;
    }

    /**
     * {@inheritdoc}
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        if (method_exists($resolver, 'setDefined')) {
            $resolver->setDefined(['parsley_trigger_event']);
        } else {
            $resolver->setOptional(['parsley_trigger_event']);
        }
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $triggerEvent = $this->triggerEvent;

        if (isset($options['parsley_trigger_event'])) {
            $triggerEvent = $options['parsley_trigger_event'];
        }

        $view->vars['attr']['data-parsley-trigger'] = $triggerEvent;
    }

    /**
     * {@inheritdoc}
     */
    public function getExtendedType()
    {
        return 'form';
    }
}

{'fraction_non_alphanumeric': 0.1328153903070662, 'fraction_numerical': 0.0022197558268590455, 'mean_word_length': 2.8030942334739803, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 18, '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': '6598892', 'n_tokens_mistral': 788, 'n_tokens_neox': 772, 'n_words': 127}