You are here

protected function EntityUser::save in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/src/Plugin/migrate/destination/EntityUser.php \Drupal\user\Plugin\migrate\destination\EntityUser::save()
  2. 10 core/modules/user/src/Plugin/migrate/destination/EntityUser.php \Drupal\user\Plugin\migrate\destination\EntityUser::save()

Saves the entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The content entity.

array $old_destination_id_values: (optional) An array of destination ID values. Defaults to an empty array.

Return value

array An array containing the entity ID.

Overrides EntityContentBase::save

File

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

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);
}