You are here

protected function EntityUser::processStubRow in Zircon Profile 8

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

Do as much population of the stub row as we can.

Parameters

\Drupal\migrate\Row $row: The row of data.

Overrides EntityContentBase::processStubRow

File

core/modules/user/src/Plugin/migrate/destination/EntityUser.php, line 114
Contains \Drupal\user\Plugin\migrate\destination\EntityUser.

Class

EntityUser
Plugin annotation @MigrateDestination( id = "entity:user" )

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->entityManager
    ->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 (Unicode::strlen($name) > USERNAME_MAX_LENGTH) {
    $row
      ->setDestinationProperty('name', Unicode::substr($name, 0, USERNAME_MAX_LENGTH));
  }
}