X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FPlugin%2Fmigrate%2Fdestination%2FEntityUser.php;fp=web%2Fcore%2Fmodules%2Fuser%2Fsrc%2FPlugin%2Fmigrate%2Fdestination%2FEntityUser.php;h=316d063bf7426912d5ad351f8b94b1fc55d5fbdc;hp=b5317beb8ceb619e09b60526a09a6e58077a63f3;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/user/src/Plugin/migrate/destination/EntityUser.php b/web/core/modules/user/src/Plugin/migrate/destination/EntityUser.php index b5317beb8..316d063bf 100644 --- a/web/core/modules/user/src/Plugin/migrate/destination/EntityUser.php +++ b/web/core/modules/user/src/Plugin/migrate/destination/EntityUser.php @@ -2,7 +2,6 @@ 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; @@ -15,6 +14,52 @@ use Drupal\migrate\Row; 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" * ) @@ -122,8 +167,8 @@ class EntityUser extends EntityContentBase { 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)); } }