8
8
use Drupal \gigya \Helper \GigyaHelper ;
9
9
use Drupal \gigya \Helper \GigyaHelperInterface ;
10
10
use Drupal \gigya_raas \Helper \GigyaRaasHelper ;
11
+ use Drupal \Core \Config \TypedConfigManagerInterface ;
11
12
12
13
13
14
class GigyaFieldmappingForm extends ConfigFormBase {
14
15
15
- private $ raas_helper ;
16
+ private $ raas_helper= NULL ;
16
17
17
- public $ api_helper = FALSE ;
18
+ public $ api_helper = NULL ;
18
19
19
- public function __construct (ConfigFactoryInterface $ config_factory ) {
20
- parent ::__construct ($ config_factory );
21
-
22
- $ this ->raas_helper = new GigyaRaasHelper ();
23
- }
24
20
25
21
/**
26
22
* Gets the configuration names that will be editable.
@@ -42,8 +38,10 @@ protected function getEditableConfigNames() {
42
38
* @return array
43
39
*/
44
40
public function buildForm (array $ form , FormStateInterface $ form_state , GigyaHelperInterface $ helper = NULL ) {
45
- $ config = $ this ->config ('gigya_raas.fieldmapping ' );
46
- $ fieldmapping_config = json_encode ($ this ->raas_helper ->getFieldMappingConfig (), JSON_PRETTY_PRINT );
41
+
42
+ if ($ this ->raas_helper == NULL ) {
43
+ $ this ->raas_helper = new GigyaRaasHelper ();
44
+ }
47
45
48
46
if ($ helper == NULL ) {
49
47
$ this ->api_helper = new GigyaHelper ();
@@ -52,6 +50,10 @@ public function buildForm(array $form, FormStateInterface $form_state, GigyaHelp
52
50
$ this ->api_helper = $ helper ;
53
51
}
54
52
53
+ $ config = $ this ->config ('gigya_raas.fieldmapping ' );
54
+ $ fieldmapping_config = json_encode ($ this ->raas_helper ->getFieldMappingConfig (), JSON_PRETTY_PRINT );
55
+
56
+
55
57
if (!$ this ->api_helper ->checkEncryptKey ()) {
56
58
$ messenger = \Drupal::service ('messenger ' );
57
59
$ messenger ->addWarning ($ this ->t ('Please go to Gigya \'s general settings to define a Gigya \'s encryption key. ' ));
@@ -126,6 +128,17 @@ public function getFormId() {
126
128
public function validateForm (array &$ form , FormStateInterface $ form_state ) {
127
129
parent ::validateForm ($ form , $ form_state );
128
130
131
+ if ($ this ->raas_helper == NULL ) {
132
+ $ this ->raas_helper = new GigyaRaasHelper ();
133
+ }
134
+
135
+ if ($ helper == NULL ) {
136
+ $ this ->api_helper = new GigyaHelper ();
137
+ }
138
+ else {
139
+ $ this ->api_helper = $ helper ;
140
+ }
141
+
129
142
/* Field mapping */
130
143
131
144
$ fieldmapping_config = $ form_state ->getValue ('gigya_fieldmapping_config ' );
@@ -212,6 +225,10 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
212
225
213
226
private function validateMappedUidFieldExists ($ form_state , string $ uid__field_mapping ) {
214
227
228
+ if ($ this ->raas_helper == NULL ) {
229
+ $ this ->raas_helper = new GigyaRaasHelper ();
230
+ }
231
+
215
232
if (!empty ($ uid__field_mapping ) and !$ this ->raas_helper ->doesFieldExist ($ uid__field_mapping )) {
216
233
$ form_state ->setErrorByName ('fieldmapping ' , $ this ->t ("The UID mapping field does not exist in your database.
217
234
Therefore, it is necessary to create the field before proceeding " ));
0 commit comments