public function preUpdate(PreUpdateEventArgs $eventArgs)
    {
        $entity = $eventArgs->getEntity();

        if ($this->checkEntityType($entity)) {
            if ($eventArgs->hasChangedField('password')) {
                $password = $entity->getPassword();
                if (!empty($password)) {
                    $encodedPassword = $this->encryptPassword($password);
                    $eventArgs->setNewValue('password', $encodedPassword);
                }
            }
        }
    }