8
8
* Headless configuration form.
9
9
*/
10
10
function headless_settings_form ($ form , &$ form_state ) {
11
+ $ help = '
12
+ <div class="headless-settings__help">
13
+ Use this form to select wich entities you would like to expose as json endpoints.
14
+ </div>
15
+ ' ;
11
16
$ form ['help ' ] = array (
12
- '#markup ' => '<div class="headless-settings__help">
13
- Use this form to select wich entities you would like to expose
14
- as json endpoints.
15
- </div> ' ,
17
+ '#markup ' => $ help ,
16
18
);
17
19
$ form ['nodes ' ] = array (
18
20
'#type ' => 'fieldset ' ,
19
21
'#title ' => 'Node Types ' ,
20
22
'#collapsible ' => TRUE ,
21
23
);
22
24
// Get the node types.
23
- $ nodeTypes = node_type_get_types ();
24
- $ nodeTypeOptions = [];
25
- foreach ( $ nodeTypes as $ key => $ type ) {
26
- $ nodeTypeOptions [$ key ] = $ key ;
25
+ $ node_types = node_type_get_types ();
26
+ $ node_type_options = [];
27
+ foreach ( $ node_types as $ key => $ type ) {
28
+ $ node_type_options [$ key ] = $ key ;
27
29
}
28
30
$ form ['nodes ' ]['node-checkboxes ' ] = array (
29
31
'#type ' => 'checkboxes ' ,
30
- '#options ' => $ nodeTypeOptions ,
32
+ '#options ' => $ node_type_options ,
31
33
'#default_value ' => _headless_get_default_options ('node ' ),
32
34
);
33
- $ vocabularyTypes = taxonomy_get_vocabularies ();
34
- $ vocabularyTypeOptions = [];
35
- foreach ( $ vocabularyTypes as $ key => $ type ) {
36
- $ vocabularyTypeOptions [$ key ] = $ key ;
35
+ $ vocabulary_types = taxonomy_get_vocabularies ();
36
+ $ vocabulary_type_options = [];
37
+ foreach ( $ vocabulary_types as $ key => $ type ) {
38
+ $ vocabulary_type_options [$ key ] = $ key ;
37
39
}
38
40
$ form ['vocabularies ' ] = array (
39
41
'#type ' => 'fieldset ' ,
@@ -43,7 +45,7 @@ function headless_settings_form($form, &$form_state) {
43
45
);
44
46
$ form ['vocabularies ' ]['vocabularies-checkboxes ' ] = array (
45
47
'#type ' => 'checkboxes ' ,
46
- '#options ' => $ vocabularyTypeOptions ,
48
+ '#options ' => $ vocabulary_type_options ,
47
49
'#default_value ' => _headless_get_default_options ('vocabularies ' ),
48
50
);
49
51
$ form ['views ' ] = array (
@@ -52,17 +54,17 @@ function headless_settings_form($form, &$form_state) {
52
54
'#collapsible ' => TRUE ,
53
55
'#collapsed ' => TRUE ,
54
56
);
55
- $ myViews = views_get_views_as_options (TRUE , 'enabled ' , NULL , TRUE , TRUE );
57
+ $ my_views = views_get_views_as_options (TRUE , 'enabled ' , NULL , TRUE , TRUE );
56
58
$ form ['views ' ]['views-checkboxes ' ] = array (
57
59
'#type ' => 'checkboxes ' ,
58
- '#options ' => $ myViews ,
60
+ '#options ' => $ my_views ,
59
61
'#default_value ' => _headless_get_default_options ('views ' ),
60
62
);
61
63
if (module_exists ('paragraphs ' )) {
62
- $ paragraphsTypes = paragraphs_bundle_load ();
63
- $ paragraphsTypeOptions = [];
64
- foreach ( $ paragraphsTypes as $ key => $ type ) {
65
- $ paragraphsTypeOptions [$ key ] = $ key ;
64
+ $ paragraphs_types = paragraphs_bundle_load ();
65
+ $ paragraphs_type_options = [];
66
+ foreach ( $ paragraphs_types as $ key => $ type ) {
67
+ $ paragraphs_type_options [$ key ] = $ key ;
66
68
}
67
69
$ form ['paragraphs ' ] = array (
68
70
'#type ' => 'fieldset ' ,
@@ -72,7 +74,7 @@ function headless_settings_form($form, &$form_state) {
72
74
);
73
75
$ form ['paragraphs ' ]['paragraphs-checkboxes ' ] = array (
74
76
'#type ' => 'checkboxes ' ,
75
- '#options ' => $ paragraphsTypeOptions ,
77
+ '#options ' => $ paragraphs_type_options ,
76
78
'#default_value ' => _headless_get_default_options ('paragraphs ' ),
77
79
);
78
80
}
@@ -92,7 +94,7 @@ function headless_settings_form($form, &$form_state) {
92
94
function headless_settings_form_submit ($ form , &$ form_state ) {
93
95
// Remove unnecessary values.
94
96
form_state_values_clean ($ form_state );
95
- foreach ($ form_state ['input ' ]['node-checkboxes ' ] as $ type => $ value ) {
97
+ foreach ($ form_state ['input ' ]['node-checkboxes ' ] as $ type => $ value ) {
96
98
if ($ value != NULL ) {
97
99
$ val = 1 ;
98
100
}
@@ -101,7 +103,7 @@ function headless_settings_form_submit($form, &$form_state) {
101
103
}
102
104
config_set ('headless.settings ' , 'node. ' . $ type , $ val );
103
105
}
104
- foreach ($ form_state ['input ' ]['vocabularies-checkboxes ' ] as $ type => $ value ) {
106
+ foreach ($ form_state ['input ' ]['vocabularies-checkboxes ' ] as $ type => $ value ) {
105
107
if ($ value != NULL ) {
106
108
$ val = 1 ;
107
109
}
@@ -110,7 +112,7 @@ function headless_settings_form_submit($form, &$form_state) {
110
112
}
111
113
config_set ('headless.settings ' , 'vocabularies. ' . $ type , $ val );
112
114
}
113
- foreach ($ form_state ['input ' ]['views-checkboxes ' ] as $ type => $ value ) {
115
+ foreach ($ form_state ['input ' ]['views-checkboxes ' ] as $ type => $ value ) {
114
116
if ($ value != NULL ) {
115
117
$ val = 1 ;
116
118
}
@@ -120,7 +122,7 @@ function headless_settings_form_submit($form, &$form_state) {
120
122
config_set ('headless.settings ' , 'views. ' . $ type , $ val );
121
123
}
122
124
if (isset ($ form_state ['input ' ]['views-checkboxes ' ])) {
123
- foreach ($ form_state ['input ' ]['views-checkboxes ' ] as $ type => $ value ) {
125
+ foreach ($ form_state ['input ' ]['views-checkboxes ' ] as $ type => $ value ) {
124
126
if ($ value != NULL ) {
125
127
$ val = 1 ;
126
128
}
@@ -131,7 +133,7 @@ function headless_settings_form_submit($form, &$form_state) {
131
133
}
132
134
}
133
135
if (isset ($ form_state ['input ' ]['paragraphs-checkboxes ' ])) {
134
- foreach ($ form_state ['input ' ]['paragraphs-checkboxes ' ] as $ type => $ value ) {
136
+ foreach ($ form_state ['input ' ]['paragraphs-checkboxes ' ] as $ type => $ value ) {
135
137
if ($ value != NULL ) {
136
138
$ val = 1 ;
137
139
}
@@ -164,7 +166,7 @@ function _headless_get_default_options($types) {
164
166
$ types = config_get ('headless.settings ' , $ types );
165
167
166
168
if (isset ($ types )) {
167
- foreach ($ types as $ key => $ type ) {
169
+ foreach ($ types as $ key => $ type ) {
168
170
if ($ type != 0 ) {
169
171
$ checked [] = $ key ;
170
172
}
0 commit comments