<commit_before><?php

namespace Luminaire\Bundle\IssueBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\Common\Persistence\ManagerRegistry;
use Luminaire\Bundle\IssueBundle\Entity\Repository\IssueRepository;
use Luminaire\Bundle\IssueBundle\Entity\IssueType as IssueTypeEntity;

/**
 * Class IssueType
 */
class IssueType extends AbstractType
{
    /**
     *
     */
    const NAME = 'luminaire_issue';

    /**
     * @var
     */
    private $doctrine;

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

    /**
     * @inheritDoc
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('summary')
            ->add('description')
            ->add('type')
            ->add('priority')
            ->add('status')
            ->add('resolution')
            ->add('reporter', null, [
                'label' => 'luminaire.issue.reporter.label'
            ])
            ->add('assignee', null, [
                'label' => 'luminaire.issue.assignee.label'
            ])
            ->add('parent', null, [
                'query_builder' => function (IssueRepository $issueRepository) {
                    $issueTypeClass = 'LuminaireIssueBundle:IssueType';
                    $type = $this->doctrine->getManagerForClass($issueTypeClass)
                        ->getRepository($issueTypeClass)->findOneBy(['name' => IssueTypeEntity::TYPE_STORY]);
                    return $issueRepository->getQueryBuilderByType($type);
                },
            ])
            ->add(
                'tags',
                'oro_tag_select',
                [
                    'label' => 'oro.tag.entity_plural_label'
                ]
            );

        $builder->add(
            'appendCollaborators',
            'oro_entity_identifier',
            [
                'class'    => 'OroUserBundle:User',
                'required' => false,
                'mapped'   => false,
                'multiple' => true,
            ]<commit_msg>Ordering issue relation entities on the issue form<commit_after><?php

namespace Luminaire\Bundle\IssueBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityRepository;
use Luminaire\Bundle\IssueBundle\Entity\Repository\IssueRepository;
use Luminaire\Bundle\IssueBundle\Entity\IssueType as IssueTypeEntity;

/**
 * Class IssueType
 */
class IssueType extends AbstractType
{
    /**
     *
     */
    const NAME = 'luminaire_issue';

    /**
     * @var
     */
    private $doctrine;

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

    /**
     * @inheritDoc
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $orderByOrderField = function (EntityRepository $repository) {
            return $repository->createQueryBuilder('e')->orderBy('e.order');
        };

        $builder
            ->add('summary')
            ->add('description')
            ->add('type', null, [
                'query_builder' => $orderByOrderField,
            ])
            ->add('priority', null, [
                'query_builder' => $orderByOrderField,
            ])
            ->add('status', null, [
                'query_builder' => $orderByOrderField,
            ])
            ->add('resolution', null, [
                'query_builder' => $orderByOrderField,
            ])
            ->add('reporter', null, [
                'label' => 'luminaire.issue.reporter.label'
            ])
            ->add('assignee', null, [
                'label' => 'luminaire.issue.assignee.label'
            ])
            ->add('parent', null, [
                'query_builder' => function (IssueRepository $issueRepository) {
                    $issueTypeClass = 'LuminaireIssueBundle:IssueType';
                    $type           = $this->doctrine->getManagerForClass($issueTypeClass)
                        ->getRepository($issueTypeClass)->findOneBy(['name' => IssueTypeEntity::TYPE_STORY]);
                    return $issueRepository->getQueryBuilderByType($type);
                },
            ])
            ->add(
                'tags',
                'oro_tag_select',
                [
                    'label' => 'oro.tag.entity_plural_label'
                ]
            );

        $builder->add(
            'appendCollaborators',
            'oro_entity_identifier',
            [
                'class'    => 'OroUserBundle:User',
                'required' => false,
                'mapped'   => false,
                'multiple' => true,
            ]
{'fraction_non_alphanumeric': 0.12598425196850394, 'fraction_numerical': 0.0, 'mean_word_length': 1.7390835579514825, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '3868551', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1318, 'n_words': 207}