@@ -31,9 +31,9 @@ protected function getAvailableVariables(): array
3131 {
3232 return [
3333 'site ' => [
34- ['name ' => 'site:name ' , 'description ' => 'Site Name ' ],
35- ['name ' => 'site:url ' , 'description ' => 'Site URL ' ],
36- ],
34+ ['name ' => 'site:name ' , 'description ' => 'Site Name ' ],
35+ ['name ' => 'site:url ' , 'description ' => 'Site URL ' ],
36+ ],
3737 'globals ' => $ this ->getGlobalVariables (),
3838 'entry ' => $ this ->getEntryFields (),
3939 'term ' => $ this ->getTermFields (),
@@ -66,15 +66,15 @@ protected function getEntryFields(): array
6666 return [];
6767 }
6868
69- $ fields = collect ($ dataTemplate ?->use_for_collection?->entryBlueprints()?->reduce(function ($ carry , $ blueprint ) {
69+ $ fields = collect ($ dataTemplate ?->use_for_collection?->entryBlueprints()?->reduce(function ($ carry , $ blueprint ) {
7070 return array_merge ($ carry , $ blueprint ->fields ()->items ()->toArray ());
7171 }, []) ?? []);
7272
73- if (class_exists (OnPageSeoBlueprint::class)) {
73+ if (class_exists (OnPageSeoBlueprint::class)) {
7474 $ fields = $ fields ->merge (OnPageSeoBlueprint::requestBlueprint ()->fields ()?->items());
7575 }
7676
77- if (!$ fields ) {
77+ if (! $ fields ) {
7878 return [];
7979 }
8080
@@ -83,9 +83,9 @@ protected function getEntryFields(): array
8383 $ collectionFields = $ fields ->map (function ($ field ) {
8484 return $ this ->setFieldData ($ field );
8585 })
86- ->filter ()
87- ->values ()
88- ->all ();
86+ ->filter ()
87+ ->values ()
88+ ->all ();
8989
9090 return array_merge ($ baseFields , $ collectionFields );
9191 }
@@ -98,15 +98,15 @@ protected function getTermFields(): array
9898 return [];
9999 }
100100
101- $ fields = collect ($ dataTemplate ?->use_for_taxonomy?->termBlueprints()?->reduce(function ($ carry , $ blueprint ) {
101+ $ fields = collect ($ dataTemplate ?->use_for_taxonomy?->termBlueprints()?->reduce(function ($ carry , $ blueprint ) {
102102 return array_merge ($ carry , $ blueprint ->fields ()->items ()->toArray ());
103103 }, []) ?? []);
104104
105- if (class_exists (OnPageSeoBlueprint::class)) {
105+ if (class_exists (OnPageSeoBlueprint::class)) {
106106 $ fields = $ fields ->merge (OnPageSeoBlueprint::requestBlueprint ()->fields ()?->items());
107107 }
108108
109- if (!$ fields ) {
109+ if (! $ fields ) {
110110 return [];
111111 }
112112
@@ -115,9 +115,9 @@ protected function getTermFields(): array
115115 $ collectionFields = $ fields ->map (function ($ field ) {
116116 return $ this ->setFieldData ($ field );
117117 })
118- ->filter ()
119- ->values ()
120- ->all ();
118+ ->filter ()
119+ ->values ()
120+ ->all ();
121121
122122 return array_merge ($ baseFields , $ collectionFields );
123123 }
@@ -132,8 +132,9 @@ protected function getGlobalVariables(): array
132132
133133 if ($ fields ) {
134134 $ globalVariables = $ fields ->items ()->map (function ($ field ) use ($ globalSet ) {
135- $ name = ($ globalSet ->handle () . ': ' . ($ field ['handle ' ] ?? '' ));
135+ $ name = ($ globalSet ->handle (). ': ' . ($ field ['handle ' ] ?? '' ));
136136 $ description = ($ field ['field ' ]['display ' ] ?? ($ field ['handle ' ] ?? '' ));
137+
137138 return $ this ->setFieldData ($ field , $ name , $ description );
138139 })->values ()->all ();
139140 }
@@ -146,27 +147,28 @@ protected function getGlobalVariables(): array
146147
147148 protected function getCollectionVariables (string $ collectionHandle , array $ field ): array
148149 {
149- if (! $ collectionHandle || $ collectionHandle === 'structured_data_templates ' ) {
150+ if (! $ collectionHandle || $ collectionHandle === 'structured_data_templates ' ) {
150151 return [];
151152 }
152153
153154 return Collection::find ($ collectionHandle )?->entryBlueprints()?->first()?->fields()?->items()?->map(function ($ entryField ) use ($ field ) {
154- $ name = ($ field ['handle ' ] . ': ' . ($ entryField ['handle ' ] ?? '' ));
155- $ description = (($ field ['field ' ]['display ' ] ?? '' ) . ': ' . ($ entryField ['field ' ]['display ' ] ?? ($ entryField ['handle ' ] ?? '' )));
155+ $ name = ($ field ['handle ' ].': ' .($ entryField ['handle ' ] ?? '' ));
156+ $ description = (($ field ['field ' ]['display ' ] ?? '' ).': ' .($ entryField ['field ' ]['display ' ] ?? ($ entryField ['handle ' ] ?? '' )));
157+
156158 return $ this ->setFieldData ($ entryField , $ name , $ description , false );
157159 })->filter ()->values ()->all ();
158160 }
159161
160162 protected function setFieldData (array $ field , ?string $ name = null , ?string $ description = null , bool $ recursive = true ): ?array
161163 {
162- if (! ($ field ['handle ' ] ?? false ) || $ field ['handle ' ] === 'parent ' || !($ field ['field ' ]['type ' ] ?? false ) || !$ this ->fieldTypeIsEligible ($ field ['field ' ]['type ' ])) {
164+ if (! ($ field ['handle ' ] ?? false ) || $ field ['handle ' ] === 'parent ' || ! ($ field ['field ' ]['type ' ] ?? false ) || ! $ this ->fieldTypeIsEligible ($ field ['field ' ]['type ' ])) {
163165 return null ;
164166 }
165167
166168 $ children = [];
167169
168- if ($ field ['field ' ]['type ' ] === 'entries ' && $ recursive ) {
169- if (! isset ($ field ['field ' ]['collections ' ][0 ])) {
170+ if ($ field ['field ' ]['type ' ] === 'entries ' && $ recursive ) {
171+ if (! isset ($ field ['field ' ]['collections ' ][0 ])) {
170172 return null ;
171173 }
172174
@@ -176,7 +178,7 @@ protected function setFieldData(array $field, ?string $name = null, ?string $des
176178 return [
177179 'name ' => $ name ?? $ field ['handle ' ],
178180 'description ' => $ description ?? ($ field ['field ' ]['display ' ] ?? $ field ['handle ' ]),
179- 'children ' => $ children
181+ 'children ' => $ children,
180182 ];
181183 }
182184}
0 commit comments