<commit_before><?php

namespace AppBundle\EventListener;

use AppBundle\DBAL\Types\RequestManagerStatusType;
use AppBundle\Entity\RequestManager;
use AppBundle\Entity\User;
use Doctrine\ORM\Event\LifecycleEventArgs;

/**
 * ProcessingManagerRequestListener class
 *
 * @author <NAME> <<EMAIL>>
 */
class ProcessingManagerRequestListener
{
    public function postUpdate(LifecycleEventArgs $args)
    {
        /** @var RequestManager $entity */
        $entity = $args->getEntity();

        if ($entity instanceof RequestManager) {
            $em       = $args->getEntityManager();
            $uow      = $em->getUnitOfWork();
            $oldValue = $uow->getEntityChangeSet($entity);

            if (RequestManagerStatusType::SENT === $oldValue['status'][0]
                && RequestManagerStatusType::ACCEPTED === $oldValue['status'][1]
            ) {
                /** @var User $user */
                $user = $em->getRepository('AppBundle:User')->find($entity->getUser()->getId());
                $user->setFullName($entity->getFullName())
                     ->setPhone($entity->getPhone())
                     ->addRole('ROLE_MANAGER');

                $em->persist($user);
                $em->flush();
            }
        }
    }
}<commit_msg>Changes of listener<commit_after><?php

namespace AppBundle\EventListener;

use AppBundle\DBAL\Types\RequestManagerStatusType;
use AppBundle\Entity\ManagerGroup;
use AppBundle\Entity\RequestManager;
use AppBundle\Entity\User;
use Doctrine\ORM\Event\LifecycleEventArgs;

/**
 * ProcessingManagerRequestListener class
 *
 * @author <NAME> <<EMAIL>>
 */
class ProcessingManagerRequestListener
{
    public function postUpdate(LifecycleEventArgs $args)
    {
        /** @var RequestManager $entity */
        $entity = $args->getEntity();

        if ($entity instanceof RequestManager) {
            $em       = $args->getEntityManager();
            $uow      = $em->getUnitOfWork();
            $oldValue = $uow->getEntityChangeSet($entity);

            if (RequestManagerStatusType::SENT === $oldValue['status'][0]
                && RequestManagerStatusType::ACCEPTED === $oldValue['status'][1]
            ) {
                /** @var User $user */
                $user = $em->getRepository('AppBundle:User')->find($entity->getUser()->getId());
                $user->setFullName($entity->getFullName())
                     ->setPhone($entity->getPhone())
                     ->addRole('ROLE_MANAGER');

                $em->persist($user);

                $requestGroups = $entity->getRequestManagerGroups();
                foreach ($requestGroups as $requestGroup) {
                    $managerGroup = (new ManagerGroup())
                        ->setGroup($requestGroup->getGroup())
                        ->setManager($user);

                    $em->persist($managerGroup);
                }

                $em->flush();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.1431972789115646, 'fraction_numerical': 0.0013605442176870747, 'mean_word_length': 2.1454545454545455, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 44, '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': '4153423', 'n_tokens_mistral': 790, 'n_tokens_neox': 760, 'n_words': 120}