<commit_before><?php

/*
 * This file is part of the OpenMiamMiam project.
 *
 * (c) Isics <<EMAIL>>
 *
 * This source file is subject to the AGPL v3 license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Isics\Bundle\OpenMiamMiamBundle\Form\Type;

use Doctrine\ORM\EntityRepository;
use Isics\Bundle\OpenMiamMiamBundle\Entity\Newsletter;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Intl\Intl;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Translation\TranslatorInterface;

class AssociationProducerExportTransferType extends AbstractType
{
    /**
     * @var TranslatorInterface $translator
     */
    protected $translator;

    /**
     * Constructor
     *
     * @param TranslatorInterface $translator Translator
     */
    public function __construct(TranslatorInterface $translator)
    {
        $this->translator = $translator;
    }

    /**
     * Builds the form
     *
     * @param FormBuilderInterface $builder
     * @param array                $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $choices = array();

        // Start at last month
        $date = new \DateTime('first day of previous month midnight');

        $formatter = new \IntlDateFormatter(
            \Locale::getDefault(),
            \IntlDateFormatter::NONE,
            \IntlDateFormatter::NONE,
            null,
            null,
            'MMMM Y'
        );

        // Store last 12 previous months
        for ($i = 0 ; $i < 12 ; $i++) {
            $choices[$date->format('Y-m')] = $this->translator->trans(
                'admin.association.producers.list.export.choice',
                array('%month%' => $formatter->format($date))
            );

            $date->modify('first day of previous month midnight');
        }

        $builder->add('month', 'choice', array(
                'choices' => $choices
            ))
            ->add('export', 'submit');
    }

    /**
     * @see AbstractType
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Isics\Bundle\OpenMiamMiamBundle\Entity\Newsletter',
        ));
    }

    /**
     * @see AbstractType
     */
    public function getName()
    {
        return 'open_miam_miam_association_producer_export_transfert';
    }
}<commit_msg>Added current month in select options in producer association's admin<commit_after><?php

/*
 * This file is part of the OpenMiamMiam project.
 *
 * (c) Isics <<EMAIL>>
 *
 * This source file is subject to the AGPL v3 license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Isics\Bundle\OpenMiamMiamBundle\Form\Type;

use Doctrine\ORM\EntityRepository;
use Isics\Bundle\OpenMiamMiamBundle\Entity\Newsletter;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Intl\Intl;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Translation\TranslatorInterface;

class AssociationProducerExportTransferType extends AbstractType
{
    /**
     * @var TranslatorInterface $translator
     */
    protected $translator;

    /**
     * Constructor
     *
     * @param TranslatorInterface $translator Translator
     */
    public function __construct(TranslatorInterface $translator)
    {
        $this->translator = $translator;
    }

    /**
     * Builds the form
     *
     * @param FormBuilderInterface $builder
     * @param array                $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $choices = array();

        // Start at last month
        $date = new \DateTime('first day of this month midnight');

        $formatter = new \IntlDateFormatter(
            \Locale::getDefault(),
            \IntlDateFormatter::NONE,
            \IntlDateFormatter::NONE,
            null,
            null,
            'MMMM Y'
        );

        // Store last 12 previous months
        for ($i = 0 ; $i < 12 ; $i++) {
            $choices[$date->format('Y-m')] = $this->translator->trans(
                'admin.association.producers.list.export.choice',
                array('%month%' => $formatter->format($date))
            );

            $date->modify('first day of previous month midnight');
        }

        $builder->add('month', 'choice', array(
                'choices' => $choices
            ))
            ->add('export', 'submit');
    }

    /**
     * @see AbstractType
     */
    public function getName()
    {
        return 'open_miam_miam_association_producer_export_transfert';
    }
}
{'fraction_non_alphanumeric': 0.11279916753381894, 'fraction_numerical': 0.002497398543184183, 'mean_word_length': 2.332871012482663, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, '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': '3440943', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1331, 'n_words': 306}