public function onUserRegister(UserRegisterEvent $event)
    {
        $masterRequest = $this
            ->requestStack
            ->getMasterRequest();

        if (!($masterRequest instanceof Request)) {
            return $this;
        }

        if (null === $this
                ->tokenStorage
                ->getToken()
        ) {
            return $this;
        }

        $token = $this->createNewToken(
            $event->getUser()
        );

        $this
            ->tokenStorage
            ->setToken($token);

        $event = new InteractiveLoginEvent(
            $masterRequest,
            $token
        );

        $this
            ->dispatcher
            ->dispatch(
                SecurityEvents::INTERACTIVE_LOGIN,
                $event
            );

        return $this;
    }
public function onUserRegister(UserRegisterEvent $event)
    {
        $masterRequest = $this
            ->requestStack
            ->getMasterRequest();

        if (!($masterRequest instanceof Request)) {
            return $this;
        }

        if (null === $this
                ->tokenStorage
                ->getToken()
        ) {
            return $this;
        }

        $token = $this->createNewToken(
            $event->getUser()
        );

        $this
            ->tokenStorage
            ->setToken($token);

        $event = new InteractiveLoginEvent(
            $masterRequest,
            $token
        );

        $this
            ->dispatcher
            ->dispatch(
                SecurityEvents::INTERACTIVE_LOGIN,
                $event
            );

        return $this;
    }
public function onUserRegister ( UserRegisterEvent $ event ) { $ masterRequest = $ this -> requestStack -> getMasterRequest ( ) ; if ( ! ( $ masterRequest instanceof Request ) ) { return $ this ; } if ( null === $ this -> tokenStorage -> getToken ( ) ) { return $ this ; } $ token = $ this -> createNewToken ( $ event -> getUser ( ) ) ; $ this -> tokenStorage -> setToken ( $ token ) ; $ event = new InteractiveLoginEvent ( $ masterRequest , $ token ) ; $ this -> dispatcher -> dispatch ( SecurityEvents :: INTERACTIVE_LOGIN , $ event ) ; return $ this ; }
Autologin users after registration.

@param UserRegisterEvent $event User registered event

@return $this Self object
Autologin users after registration .