@@ -80,16 +80,16 @@ private static function initPayloadFromRequestBody(): ?object
80
80
* If it does not find a valid locale, it will default to 'la' (Latin).
81
81
*
82
82
* If the object does not have a 'region' property, it will not set the
83
- * 'REGION ' key in the returned array.
83
+ * 'region ' key in the returned array.
84
84
*
85
85
* If the object does not have a 'year' property, it will not set the
86
- * 'YEAR ' key in the returned array.
86
+ * 'year ' key in the returned array.
87
87
*
88
88
* @param ?object $payload the JSON or YAML encoded object or null if the
89
89
* request body was not a JSON or YAML encoded object
90
90
* @return array the initialized request parameters
91
91
*/
92
- private static function initPayload (?object $ payload ): array
92
+ private static function initGetPostParams (?object $ payload ): array
93
93
{
94
94
$ data = [];
95
95
if ($ payload !== null && property_exists ($ payload , 'locale ' )) {
@@ -108,6 +108,9 @@ private static function initPayload(?object $payload): array
108
108
if (property_exists ($ payload , 'year ' )) {
109
109
$ data ["year " ] = $ payload ->year ;
110
110
}
111
+ if (property_exists ($ payload , 'include_empty ' )) {
112
+ $ data ["include_empty " ] = $ payload ->include_empty ;
113
+ }
111
114
return $ data ;
112
115
}
113
116
@@ -132,12 +135,12 @@ private static function initRequestParams(): array
132
135
if (in_array (self ::$ Core ->getRequestMethod (), [RequestMethod::POST , RequestMethod::PUT , RequestMethod::PATCH ])) {
133
136
$ payload = self ::initPayloadFromRequestBody ();
134
137
if (self ::$ Core ->getRequestMethod () === RequestMethod::POST ) {
135
- $ data = self ::initPayload ($ payload );
138
+ $ data = self ::initGetPostParams ($ payload );
136
139
} else {
137
140
$ data ["PAYLOAD " ] = $ payload ;
138
141
}
139
142
} elseif (self ::$ Core ->getRequestMethod () === RequestMethod::GET ) {
140
- $ data = self ::initPayload ((object )$ _GET );
143
+ $ data = self ::initGetPostParams ((object )$ _GET );
141
144
}
142
145
return $ data ;
143
146
}
@@ -418,5 +421,22 @@ public static function init(array $requestPathParts = [])
418
421
}
419
422
// we only set the request parameters after we have collected the MissalRegions and MissalYears
420
423
self ::$ params ->setData (self ::initRequestParams ());
424
+
425
+ // If an explicit request is made to include all Missals defined in the RomanMissal enum,
426
+ // even if there is no data for them in the jsondata/sourcedata/missals directory,
427
+ // we add them to the response.
428
+ if (self ::$ params ->IncludeEmpty ) {
429
+ $ allMissals = RomanMissal::produceMetadata (true );
430
+ foreach ($ allMissals as $ missal ) {
431
+ if (null === array_find (self ::$ missalsIndex ->litcal_missals , function ($ m ) use ($ missal ) {
432
+ return $ m ->missal_id === $ missal ->missal_id ;
433
+ })) {
434
+ //$missal->api_path = false;
435
+ self ::$ missalsIndex ->litcal_missals [] = $ missal ;
436
+ self ::$ params ->addMissalRegion ($ missal ->region );
437
+ self ::$ params ->addMissalYear ($ missal ->year_published );
438
+ }
439
+ }
440
+ }
421
441
}
422
442
}
0 commit comments