From 1480cba00964dbb239a46dc62ab9cdc205be6e33 Mon Sep 17 00:00:00 2001 From: bach Date: Mon, 9 Aug 2021 08:47:14 +0200 Subject: [PATCH] added userverification on user migration --- .../src/Plugin/migrate/source/D7Users.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/web/modules/custom/materio_migrate/src/Plugin/migrate/source/D7Users.php b/web/modules/custom/materio_migrate/src/Plugin/migrate/source/D7Users.php index a913ca8a..b511d71c 100644 --- a/web/modules/custom/materio_migrate/src/Plugin/migrate/source/D7Users.php +++ b/web/modules/custom/materio_migrate/src/Plugin/migrate/source/D7Users.php @@ -2,8 +2,16 @@ namespace Drupal\materio_migrate\Plugin\migrate\source; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\migrate\Row; use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity; +use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Extension\ModuleHandler; +use Drupal\Core\State\StateInterface; +use Drupal\migrate\Plugin\MigrationInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\user_email_verification\UserEmailVerificationInterface; /** * Drupal 7 user source from database. @@ -15,6 +23,46 @@ use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity; */ class D7Users extends FieldableEntity { + /** + * User email verification helper service. + * + * @var \Drupal\user_email_verification\UserEmailVerificationInterface + */ + protected $userEmailVerification; + + + /** + * Constructs a new UserEmailVerificationRequestForm object. + * + * @param \Drupal\user_email_verification\UserEmailVerificationInterface $user_email_verification_service + * User email verification helper service. + * @param \Drupal\Core\Session\AccountProxyInterface $current_user + * The current active user. + * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack + * The request stack. + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, UserEmailVerificationInterface $user_email_verification_service) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); + $this->userEmailVerification = $user_email_verification_service; + } + + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $migration, + $container->get('state'), + $container->get('entity.manager'), + $container->get('module_handler'), + $container->get('user_email_verification.service') + ); + } + /** * {@inheritdoc} */ @@ -180,6 +228,9 @@ class D7Users extends FieldableEntity { // abo01-C 2 (web+showroom) } + // set the user's email ferified + $this->userEmailVerification->setEmailVerifiedByUserId($row->getSourceProperty('uid')); + // record migration errors in field_memo if(isset($memo)){ $field_memo = $row->getSourceProperty('field_memo');