public function postAuthProcess(Request $request, User $user)
    {
        $date = new \DateTime('+' . (int) $this->getConf()->get(['registry', 'actions', 'validation-reminder-days']) . ' days');
        $manager = $this->getEntityManager();

        foreach ($this->getValidationParticipantRepository()->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) {
            $validationSession = $participant->getSession();
            $basket = $validationSession->getBasket();

            if (null === $token = $this->getTokenRepository()->findValidationToken($basket, $participant->getUser())) {
                continue;
            }

            $url = $this->app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]);
            $this->dispatch(PhraseaEvents::VALIDATION_REMINDER, new ValidationEvent($participant, $basket, $url));

            $participant->setReminded(new \DateTime('now'));
            $manager->persist($participant);
        }

        $manager->flush();

        $session = $this->getAuthenticator()->openAccount($user);

        if ($user->getLocale() != $this->app['locale']) {
            $user->setLocale($this->app['locale']);
        }

        $width = $height = null;
        if ($request->cookies->has('screen')) {
            $data = array_filter((explode('x', $request->cookies->get('screen', ''))));
            if (count($data) === 2) {
                $width = $data[0];
                $height = $data[1];
            }
        }
        $session->setIpAddress($request->getClientIp())
            ->setScreenHeight($height)
            ->setScreenWidth($width);

        $manager->persist($session);
        $manager->flush();

        return $session;
    }
public function postAuthProcess(Request $request, User $user)
    {
        $date = new \DateTime('+' . (int) $this->getConf()->get(['registry', 'actions', 'validation-reminder-days']) . ' days');
        $manager = $this->getEntityManager();

        foreach ($this->getValidationParticipantRepository()->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) {
            $validationSession = $participant->getSession();
            $basket = $validationSession->getBasket();

            if (null === $token = $this->getTokenRepository()->findValidationToken($basket, $participant->getUser())) {
                continue;
            }

            $url = $this->app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]);
            $this->dispatch(PhraseaEvents::VALIDATION_REMINDER, new ValidationEvent($participant, $basket, $url));

            $participant->setReminded(new \DateTime('now'));
            $manager->persist($participant);
        }

        $manager->flush();

        $session = $this->getAuthenticator()->openAccount($user);

        if ($user->getLocale() != $this->app['locale']) {
            $user->setLocale($this->app['locale']);
        }

        $width = $height = null;
        if ($request->cookies->has('screen')) {
            $data = array_filter((explode('x', $request->cookies->get('screen', ''))));
            if (count($data) === 2) {
                $width = $data[0];
                $height = $data[1];
            }
        }
        $session->setIpAddress($request->getClientIp())
            ->setScreenHeight($height)
            ->setScreenWidth($width);

        $manager->persist($session);
        $manager->flush();

        return $session;
    }
public function postAuthProcess ( Request $ request , User $ user ) { $ date = new \ DateTime ( '+' . ( int ) $ this -> getConf ( ) -> get ( [ 'registry' , 'actions' , 'validation-reminder-days' ] ) . ' days' ) ; $ manager = $ this -> getEntityManager ( ) ; foreach ( $ this -> getValidationParticipantRepository ( ) -> findNotConfirmedAndNotRemindedParticipantsByExpireDate ( $ date ) as $ participant ) { $ validationSession = $ participant -> getSession ( ) ; $ basket = $ validationSession -> getBasket ( ) ; if ( null === $ token = $ this -> getTokenRepository ( ) -> findValidationToken ( $ basket , $ participant -> getUser ( ) ) ) { continue ; } $ url = $ this -> app -> url ( 'lightbox_validation' , [ 'basket' => $ basket -> getId ( ) , 'LOG' => $ token -> getValue ( ) ] ) ; $ this -> dispatch ( PhraseaEvents :: VALIDATION_REMINDER , new ValidationEvent ( $ participant , $ basket , $ url ) ) ; $ participant -> setReminded ( new \ DateTime ( 'now' ) ) ; $ manager -> persist ( $ participant ) ; } $ manager -> flush ( ) ; $ session = $ this -> getAuthenticator ( ) -> openAccount ( $ user ) ; if ( $ user -> getLocale ( ) != $ this -> app [ 'locale' ] ) { $ user -> setLocale ( $ this -> app [ 'locale' ] ) ; } $ width = $ height = null ; if ( $ request -> cookies -> has ( 'screen' ) ) { $ data = array_filter ( ( explode ( 'x' , $ request -> cookies -> get ( 'screen' , '' ) ) ) ) ; if ( count ( $ data ) === 2 ) { $ width = $ data [ 0 ] ; $ height = $ data [ 1 ] ; } } $ session -> setIpAddress ( $ request -> getClientIp ( ) ) -> setScreenHeight ( $ height ) -> setScreenWidth ( $ width ) ; $ manager -> persist ( $ session ) ; $ manager -> flush ( ) ; return $ session ; }
move this in an event
move this in an event