-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge-request-2-post-save-hook.patch
55 lines (49 loc) · 1.58 KB
/
merge-request-2-post-save-hook.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 9c04251680acee249fa960440d4892b00a41ecd5 Mon Sep 17 00:00:00 2001
From: Matei Stanca <i@ambientimpact.com>
Date: Sun, 18 Jul 2021 21:48:44 -0400
Subject: [PATCH] Added hook_bulk_user_registration_user_postsave().
---
bulk_user_registration.api.php | 19 +++++++++++++++++++
src/BulkUserRegistration.php | 4 ++++
2 files changed, 23 insertions(+)
diff --git a/bulk_user_registration.api.php b/bulk_user_registration.api.php
index a8146b4..792b61b 100644
--- a/bulk_user_registration.api.php
+++ b/bulk_user_registration.api.php
@@ -46,3 +46,22 @@ function hook_bulk_user_registration_user_presave(UserInterface $user, array $da
$user->set('identifier', trim($data['identifier']));
}
}
+
+/**
+ * Alter the user object after it has been saved following import of CSV data.
+ *
+ * Typically used to perform tasks that require the imported user to exist in
+ * the database.
+ *
+ * @param \Drupal\user\UserInterface $user
+ * The user object.
+ * @param array $data
+ * The raw CSV data.
+ *
+ * @see hook_bulk_user_registration_extra_fields()
+ */
+function hook_bulk_user_registration_user_postsave(UserInterface $user, array $data) {
+
+ // Do stuff.
+
+}
diff --git a/src/BulkUserRegistration.php b/src/BulkUserRegistration.php
index 87961f1..ef87f4b 100644
--- a/src/BulkUserRegistration.php
+++ b/src/BulkUserRegistration.php
@@ -96,6 +96,10 @@ class BulkUserRegistration implements BulkUserRegistrationInterface {
$user->save();
+ $this->moduleHandler->invokeAll(
+ 'bulk_user_registration_user_postsave', [$user, $userData]
+ );
+
return $user;
}
--
GitLab