6
6
namespace Magento \Customer \Ui \Component \DataProvider ;
7
7
8
8
use Magento \Customer \Api \CustomerMetadataInterface ;
9
+ use Magento \Customer \Model \AccountManagement ;
9
10
use Magento \Framework \Api \AttributeValueFactory ;
11
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
10
12
use Magento \Framework \Exception \NoSuchEntityException ;
11
13
use Magento \Customer \Api \GroupRepositoryInterface ;
14
+ use Magento \Store \Model \ScopeInterface ;
12
15
use Magento \Store \Model \StoreManagerInterface ;
13
16
14
17
/**
@@ -31,6 +34,21 @@ class Document extends \Magento\Framework\View\Element\UiComponent\DataProvider\
31
34
*/
32
35
private static $ websiteAttributeCode = 'website_id ' ;
33
36
37
+ /**
38
+ * @var string
39
+ */
40
+ private static $ websiteIdAttributeCode = 'original_website_id ' ;
41
+
42
+ /**
43
+ * @var string
44
+ */
45
+ private static $ confirmationAttributeCode = 'confirmation ' ;
46
+
47
+ /**
48
+ * @var string
49
+ */
50
+ private static $ accountLockAttributeCode = 'lock_expires ' ;
51
+
34
52
/**
35
53
* @var CustomerMetadataInterface
36
54
*/
@@ -46,23 +64,31 @@ class Document extends \Magento\Framework\View\Element\UiComponent\DataProvider\
46
64
*/
47
65
private $ storeManager ;
48
66
67
+ /**
68
+ * @var ScopeConfigInterface
69
+ */
70
+ private $ scopeConfig ;
71
+
49
72
/**
50
73
* Document constructor.
51
74
* @param AttributeValueFactory $attributeValueFactory
52
75
* @param GroupRepositoryInterface $groupRepository
53
76
* @param CustomerMetadataInterface $customerMetadata
54
77
* @param StoreManagerInterface $storeManager
78
+ * @param ScopeConfigInterface $scopeConfig
55
79
*/
56
80
public function __construct (
57
81
AttributeValueFactory $ attributeValueFactory ,
58
82
GroupRepositoryInterface $ groupRepository ,
59
83
CustomerMetadataInterface $ customerMetadata ,
60
- StoreManagerInterface $ storeManager
84
+ StoreManagerInterface $ storeManager ,
85
+ ScopeConfigInterface $ scopeConfig
61
86
) {
62
87
parent ::__construct ($ attributeValueFactory );
63
88
$ this ->customerMetadata = $ customerMetadata ;
64
89
$ this ->groupRepository = $ groupRepository ;
65
90
$ this ->storeManager = $ storeManager ;
91
+ $ this ->scopeConfig = $ scopeConfig ;
66
92
}
67
93
68
94
/**
@@ -80,6 +106,12 @@ public function getCustomAttribute($attributeCode)
80
106
case self ::$ websiteAttributeCode :
81
107
$ this ->setWebsiteValue ();
82
108
break ;
109
+ case self ::$ confirmationAttributeCode :
110
+ $ this ->setConfirmationValue ();
111
+ break ;
112
+ case self ::$ accountLockAttributeCode :
113
+ $ this ->setAccountLockValue ();
114
+ break ;
83
115
}
84
116
return parent ::getCustomAttribute ($ attributeCode );
85
117
}
@@ -133,5 +165,47 @@ private function setWebsiteValue()
133
165
$ value = $ this ->getData (self ::$ websiteAttributeCode );
134
166
$ list = $ this ->storeManager ->getWebsites ();
135
167
$ this ->setCustomAttribute (self ::$ websiteAttributeCode , $ list [$ value ]->getName ());
168
+ $ this ->setCustomAttribute (self ::$ websiteIdAttributeCode , $ value );
169
+ }
170
+
171
+ /**
172
+ * Update confirmation value
173
+ * Method set confirmation text value to match what is shown in grid
174
+ * @return void
175
+ */
176
+ private function setConfirmationValue ()
177
+ {
178
+ $ value = $ this ->getData (self ::$ confirmationAttributeCode );
179
+ $ websiteId = $ this ->getData (self ::$ websiteIdAttributeCode ) ?: $ this ->getData (self ::$ websiteAttributeCode );
180
+ $ isConfirmationRequired = (bool )$ this ->scopeConfig ->getValue (
181
+ AccountManagement::XML_PATH_IS_CONFIRM ,
182
+ ScopeInterface::SCOPE_WEBSITES ,
183
+ $ websiteId );
184
+
185
+ $ valueText = !$ isConfirmationRequired ?
186
+ __ ('Confirmation Not Required ' )
187
+ : ($ value === null ? __ ('Confirmed ' ) : __ ('Confirmation Required ' ));
188
+
189
+ $ this ->setCustomAttribute (self ::$ confirmationAttributeCode , $ valueText );
190
+ }
191
+
192
+ /**
193
+ * Update lock expires value
194
+ * Method set account lock text value to match what is shown in grid
195
+ * @return void
196
+ */
197
+ private function setAccountLockValue ()
198
+ {
199
+ $ value = $ this ->getDataByPath (self ::$ accountLockAttributeCode );
200
+
201
+ $ valueText = __ ('Unlocked ' );
202
+ if ($ value !== null ) {
203
+ $ lockExpires = new \DateTime ($ value );
204
+ if ($ lockExpires > new \DateTime ()) {
205
+ $ valueText = __ ('Locked ' );
206
+ }
207
+ }
208
+
209
+ $ this ->setCustomAttribute (self ::$ accountLockAttributeCode , $ valueText );
136
210
}
137
211
}
0 commit comments