function EntityUser::processStubRow

Same name in other branches
  1. 8.9.x core/modules/user/src/Plugin/migrate/destination/EntityUser.php \Drupal\user\Plugin\migrate\destination\EntityUser::processStubRow()
  2. 10 core/modules/user/src/Plugin/migrate/destination/EntityUser.php \Drupal\user\Plugin\migrate\destination\EntityUser::processStubRow()
  3. 11.x 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 159

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);
    // 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.
    $field_definitions = $this->entityFieldManager
        ->getFieldDefinitions($this->storage
        ->getEntityTypeId(), $this->getKey('bundle'));
    $mail = EmailItem::generateSampleValue($field_definitions['mail']);
    $row->setDestinationProperty('mail', reset($mail));
    // @todo Work-around for https://www.drupal.org/node/2602066.
    $name = $row->getDestinationProperty('name');
    if (is_array($name)) {
        $name = reset($name);
    }
    if (mb_strlen($name) > UserInterface::USERNAME_MAX_LENGTH) {
        $row->setDestinationProperty('name', mb_substr($name, 0, UserInterface::USERNAME_MAX_LENGTH));
    }
}

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