<commit_before><?php

/*
 * This file is part of the Integrated package.
 *
 * (c) e-Active B.V. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Integrated\Bundle\UserBundle\Form\Type;

use Integrated\Bundle\UserBundle\Model\UserManagerInterface;

use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
 * @author <NAME> <<EMAIL>>
 */
class ProfileType extends AbstractType
{
	/**
	 * @var UserManagerInterface
	 */
	private $manager;

	/**
	 * @var ChoiceListInterface
	 */
	private $choiceList;

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

	/**
	 * @inheritdoc
	 */
	public function buildForm(FormBuilderInterface $builder, array $options)
	{
		if ($options['multiple']) {
			$builder->addViewTransformer(new CollectionToArrayTransformer(), true);
		}
	}

	/**
     * @inheritdoc
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
		$resolver->setDefaults(array(
			'choices'     => null,
			'choice_list' => function(Options $options) { return $this->getChoiceList(); },
			'multiple'    => false,
			'expanded'    => false
		));
    }

	/**
	 * @inheritdoc
	 */
	public function getParent()
	{
		return 'choice';
	}

	/**
     * @inheritdoc
     */
    public function getName()
    {
        return 'integrated_user_profile_type';
    }

	/**
	 * @return ChoiceListInterface
	 */
	public function getChoiceList()
	{
		if ($this->choiceList === null) {
			$this->choiceList = new ObjectChoiceList($this->getManager()->findAll(), 'name', [], null, 'id');
		}

		return $this->choiceList;
	}

	/**
	 * @return UserManagerInterface
	 */
	public function getManager()
	{
		return $this->manager;
	}
}<commit_msg>Fixed a bug where name (which is not in the interface) was used instead of username.<commit_after><?php

/*
 * This file is part of the Integrated package.
 *
 * (c) e-Active B.V. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Integrated\Bundle\UserBundle\Form\Type;

use Integrated\Bundle\UserBundle\Model\UserManagerInterface;

use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;

use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
 * @author <NAME> <<EMAIL>>
 */
class ProfileType extends AbstractType
{
	/**
	 * @var UserManagerInterface
	 */
	private $manager;

	/**
	 * @var ChoiceListInterface
	 */
	private $choiceList;

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

	/**
	 * @inheritdoc
	 */
	public function buildForm(FormBuilderInterface $builder, array $options)
	{
		if ($options['multiple']) {
			$builder->addViewTransformer(new CollectionToArrayTransformer(), true);
		}
	}

	/**
     * @inheritdoc
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
		$resolver->setDefaults(array(
			'choices'     => null,
			'choice_list' => function(Options $options) { return $this->getChoiceList(); },
			'multiple'    => false,
			'expanded'    => false
		));
    }

	/**
	 * @inheritdoc
	 */
	public function getParent()
	{
		return 'choice';
	}

	/**
     * @inheritdoc
     */
    public function getName()
    {
        return 'integrated_user_profile_type';
    }

	/**
	 * @return ChoiceListInterface
	 */
	public function getChoiceList()
	{
		if ($this->choiceList === null) {
			$this->choiceList = new ObjectChoiceList($this->getManager()->findAll(), 'username', [], null, 'id');
		}

		return $this->choiceList;
	}

	/**
	 * @return UserManagerInterface
	 */
	public function getManager()
	{
		return $this->manager;
	}
}
{'fraction_non_alphanumeric': 0.13305476138113043, 'fraction_numerical': 0.0, 'mean_word_length': 3.8641711229946525, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 41, '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': '4088002', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1350, 'n_words': 291}