function EntityUser::save

Same name in other branches
  1. 9 core/modules/user/src/Plugin/migrate/destination/EntityUser.php \Drupal\user\Plugin\migrate\destination\EntityUser::save()
  2. 8.9.x core/modules/user/src/Plugin/migrate/destination/EntityUser.php \Drupal\user\Plugin\migrate\destination\EntityUser::save()
  3. 11.x core/modules/user/src/Plugin/migrate/destination/EntityUser.php \Drupal\user\Plugin\migrate\destination\EntityUser::save()

Overrides EntityContentBase::save

File

core/modules/user/src/Plugin/migrate/destination/EntityUser.php, line 139

Class

EntityUser
Provides a destination plugin for migrating user entities.

Namespace

Drupal\user\Plugin\migrate\destination

Code

protected function save(ContentEntityInterface $entity, array $old_destination_id_values = []) {
    // Do not overwrite the root account password.
    if ($entity->id() != 1) {
        // Set the pre_hashed password so that the PasswordItem field does not hash
        // already hashed passwords. If the md5_passwords configuration option is
        // set we need to rehash the password and prefix with a U.
        // @see \Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem::preSave()
        $entity->pass->pre_hashed = TRUE;
        if (isset($this->configuration['md5_passwords'])) {
            $entity->pass->value = 'U' . $this->password
                ->hash($entity->pass->value);
        }
    }
    return parent::save($entity, $old_destination_id_values);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.