function EntityUser::processStubRow

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

Overrides EntityContentBase::processStubRow

File

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

Class

EntityUser
Provides a destination plugin for migrating user entities.

Namespace

Drupal\user\Plugin\migrate\destination

Code

protected function processStubRow(Row $row) {
    parent::processStubRow($row);
    $field_definitions = $this->entityFieldManager
        ->getFieldDefinitions($this->storage
        ->getEntityTypeId(), $this->getKey('bundle'));
    // Name is generated using a dedicated sample value generator to ensure
    // uniqueness and a valid length.
    // @todo Remove this as part of https://www.drupal.org/node/3352288.
    $name = UserNameItem::generateSampleValue($field_definitions['name']);
    $row->setDestinationProperty('name', reset($name));
    // Email address is not defined as required in the base field definition but
    // is effectively required by the UserMailRequired constraint. This means
    // that Entity::processStubRow() did not populate it - we do it here.
    $mail = EmailItem::generateSampleValue($field_definitions['mail']);
    $row->setDestinationProperty('mail', reset($mail));
}

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