namespace Drupal\user\Plugin\migrate\destination;
-use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
+ * Provides a destination plugin for migrating user entities.
+ *
+ * Example:
+ *
+ * The example below migrates users and preserves original passwords from a
+ * source that has passwords as MD5 hashes without salt. The passwords will be
+ * salted and re-hashed before they are saved to the destination Drupal
+ * database. The MD5 hash used in the example is a hash of 'password'.
+ *
+ * The example uses the EmbeddedDataSource source plugin for the sake of
+ * simplicity. The mapping between old user_ids and new Drupal uids is saved in
+ * the migration map table.
+ * @code
+ * id: custom_user_migration
+ * label: Custom user migration
+ * source:
+ * plugin: embedded_data
+ * data_rows:
+ * -
+ * user_id: 1
+ * name: johnsmith
+ * mail: johnsmith@example.com
+ * hash: '5f4dcc3b5aa765d61d8327deb882cf99'
+ * ids:
+ * user_id:
+ * type: integer
+ * process:
+ * name: name
+ * mail: mail
+ * pass: hash
+ * status:
+ * plugin: default_value
+ * default_value: 1
+ * destination:
+ * plugin: entity:user
+ * md5_passwords: true
+ * @endcode
+ *
+ * For configuration options inherited from the parent class, refer to
+ * \Drupal\migrate\Plugin\migrate\destination\EntityContentBase.
+ *
+ * The example above is about migrating an MD5 password hash. For more examples
+ * on different password hash types and a list of other user properties, refer
+ * to the handbook documentation:
+ * @see https://www.drupal.org/docs/8/api/migrate-api/migrate-destination-plugins-examples/migrating-users
+ *
* @MigrateDestination(
* id = "entity:user"
* )
if (is_array($name)) {
$name = reset($name);
}
- if (Unicode::strlen($name) > USERNAME_MAX_LENGTH) {
- $row->setDestinationProperty('name', Unicode::substr($name, 0, USERNAME_MAX_LENGTH));
+ if (mb_strlen($name) > USERNAME_MAX_LENGTH) {
+ $row->setDestinationProperty('name', mb_substr($name, 0, USERNAME_MAX_LENGTH));
}
}