<commit_before><?php
/**
 * @package     Mautic
 * @copyright   2014 Mautic Contributors. All rights reserved.
 * @author      Mautic
 * @link        http://mautic.org
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

namespace Mautic\CampaignBundle\Form\Type;

use Mautic\CoreBundle\Factory\MauticFactory;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
 * Class CampaignListType
 *
 * @package Mautic\CampaignBundle\Form\Type
 */
class CampaignListType extends AbstractType
{

    private $model;

    /**
     * @param MauticFactory $factory
     */
    public function __construct(MauticFactory $factory) {
        $this->model = $factory->getModel('campaign');
        $this->thisString = $factory->getTranslator()->trans('mautic.campaign.form.thiscampaign');
    }

    /**
     * {@inheritdoc}
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $model = $this->model;
        $msg   = $this->thisString;
        $resolver->setDefaults(array(
            'choices'       => function (Options $options) use ($model, $msg) {
                $choices = array();
                $campaigns = $model->getRepository()->getPublishedCampaigns(null, null, true);
                foreach ($campaigns as $campaign) {
                    $choices[$campaign['id']] = $campaign['id'] . ':' . $campaign['name'];
                }

                //sort by language
                ksort($choices);

                if ($options['include_this']) {
                    $choices = array('this' => $msg) + $choices;
                }

                return $choices;
            },
            'empty_value'   => false,
            'expanded'      => false,
            'multiple'      => true,
            'required'      => false,
            'include_this'  => false
        ));
    }

    /**
     * @return string<commit_msg>Update to change sort order<commit_after><?php
/**
 * @package     Mautic
 * @copyright   2014 Mautic Contributors. All rights reserved.
 * @author      Mautic
 * @link        http://mautic.org
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

namespace Mautic\CampaignBundle\Form\Type;

use Mautic\CoreBundle\Factory\MauticFactory;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
 * Class CampaignListType
 *
 * @package Mautic\CampaignBundle\Form\Type
 */
class CampaignListType extends AbstractType
{

    private $model;

    /**
     * @param MauticFactory $factory
     */
    public function __construct(MauticFactory $factory) {
        $this->model = $factory->getModel('campaign');
        $this->thisString = $factory->getTranslator()->trans('mautic.campaign.form.thiscampaign');
    }

    /**
     * {@inheritdoc}
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $model = $this->model;
        $msg   = $this->thisString;
        $resolver->setDefaults(array(
            'choices'       => function (Options $options) use ($model, $msg) {
                $choices = array();
                $campaigns = $model->getRepository()->getPublishedCampaigns(null, null, true);
                foreach ($campaigns as $campaign) {
                    $choices[$campaign['id']] = $campaign['id'] . ':' . $campaign['name'];
                }

                //sort by language
                sort($choices);

                if ($options['include_this']) {
                    $choices = array('this' => $msg) + $choices;
                }

                return $choices;
            },
            'empty_value'   => false,
            'expanded'      => false,
            'multiple'      => true,
            'required'      => false,
            'include_this'  => false
        ));
    }

    /**
     * @return string
{'fraction_non_alphanumeric': 0.13639770172370722, 'fraction_numerical': 0.0034973769672745443, 'mean_word_length': 2.040242976461655, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6644195', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1121, 'n_words': 207}