public function preUpdate(User $user, PreUpdateEventArgs $event)
    {
        if ($event->hasChangedField('password')) {
            $event->setNewValue('password', $this->encodePassword($user));
        }
    }
public function preUpdate(User $user, PreUpdateEventArgs $event)
    {
        if ($event->hasChangedField('password')) {
            $event->setNewValue('password', $this->encodePassword($user));
        }
    }
public function preUpdate ( User $ user , PreUpdateEventArgs $ event ) { if ( $ event -> hasChangedField ( 'password' ) ) { $ event -> setNewValue ( 'password' , $ this -> encodePassword ( $ user ) ) ; } }
Encodes the password when a User is updated and value has changed.

@param User               $user
@param PreUpdateEventArgs $event
Encodes the password when a User is updated and value has changed .