public function submit(FormEvent $event)
    {
        $user = $event->getData();
        if (null === $user) {
            return;
        }
        if ($this->currentUser !== null && $this->currentUser !== $user && $event->getForm()->has('activated')) {
            $activated = $event->getForm()->get('activated')->getData();
            if ($activated && $user->getRegistrationToken()) {
                $user->setRegistrationToken(null);
            } elseif (!$activated && !$user->getRegistrationToken()) {
                $user->setRegistrationToken(hash("sha1",rand()));
            }
        }
    }
public function submit(FormEvent $event)
    {
        $user = $event->getData();
        if (null === $user) {
            return;
        }
        if ($this->currentUser !== null && $this->currentUser !== $user && $event->getForm()->has('activated')) {
            $activated = $event->getForm()->get('activated')->getData();
            if ($activated && $user->getRegistrationToken()) {
                $user->setRegistrationToken(null);
            } elseif (!$activated && !$user->getRegistrationToken()) {
                $user->setRegistrationToken(hash("sha1",rand()));
            }
        }
    }
public function submit ( FormEvent $ event ) { $ user = $ event -> getData ( ) ; if ( null === $ user ) { return ; } if ( $ this -> currentUser !== null && $ this -> currentUser !== $ user && $ event -> getForm ( ) -> has ( 'activated' ) ) { $ activated = $ event -> getForm ( ) -> get ( 'activated' ) -> getData ( ) ; if ( $ activated && $ user -> getRegistrationToken ( ) ) { $ user -> setRegistrationToken ( null ) ; } elseif ( ! $ activated && ! $ user -> getRegistrationToken ( ) ) { $ user -> setRegistrationToken ( hash ( "sha1" , rand ( ) ) ) ; } } }
Checkt form fields by SUBMIT FormEvent

@param FormEvent $event
Checkt form fields by SUBMIT FormEvent