@@ -278,34 +278,39 @@ public function __construct()
278
278
*/
279
279
private static function retrieveSchemaForCategory (string $ category , ?string $ dataPath = null ): ?string
280
280
{
281
+ $ versionedPattern = "/\/api\/v[4-9]\// " ;
282
+ $ versionedReplacement = "/api/dev/ " ;
283
+ $ isVersionedDataPath = preg_match ($ versionedPattern , $ dataPath ) !== false ;
281
284
switch ($ category ) {
282
285
case 'universalcalendar ' :
286
+ if ($ isVersionedDataPath ) {
287
+ $ versionedDataPath = preg_replace ($ versionedPattern , $ versionedReplacement , $ dataPath );
288
+ if (array_key_exists ($ versionedDataPath , Health::DATA_PATH_TO_SCHEMA )) {
289
+ $ tempSchemaPath = Health::DATA_PATH_TO_SCHEMA [ $ versionedDataPath ];
290
+ return preg_replace ($ versionedPattern , $ versionedReplacement , $ tempSchemaPath );
291
+ }
292
+ }
283
293
if (array_key_exists ($ dataPath , Health::DATA_PATH_TO_SCHEMA )) {
284
294
return Health::DATA_PATH_TO_SCHEMA [ $ dataPath ];
285
295
}
286
- $ versionedDataPath = preg_replace ("/\/api\/v[4-9]\// " , "/api/dev/ " , $ dataPath );
287
- if (array_key_exists ($ versionedDataPath , Health::DATA_PATH_TO_SCHEMA )) {
288
- $ tempSchemaPath = Health::DATA_PATH_TO_SCHEMA [ $ versionedDataPath ];
289
- return preg_replace ("/\/api\/v[4-9]\// " , "/api/dev/ " , $ tempSchemaPath );
290
- }
291
296
return null ;
292
297
case 'nationalcalendar ' :
293
- return LitSchema::NATIONAL ;
298
+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: NATIONAL ) : LitSchema::NATIONAL ;
294
299
case 'diocesancalendar ' :
295
- return LitSchema::DIOCESAN ;
300
+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: DIOCESAN ) : LitSchema::DIOCESAN ;
296
301
case 'widerregioncalendar ' :
297
- return LitSchema::WIDERREGION ;
302
+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: WIDERREGION ) : LitSchema::WIDERREGION ;
298
303
case 'propriumdesanctis ' :
299
- return LitSchema::PROPRIUMDESANCTIS ;
304
+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: PROPRIUMDESANCTIS ) : LitSchema::PROPRIUMDESANCTIS ;
300
305
case 'resourceDataCheck ' :
301
306
if (
302
307
preg_match ("/\/missals\/[_A-Z0-9]+$/ " , $ dataPath )
303
308
) {
304
- return LitSchema::PROPRIUMDESANCTIS ;
309
+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: PROPRIUMDESANCTIS ) : LitSchema::PROPRIUMDESANCTIS ;
305
310
} elseif (
306
311
preg_match ("/\/events\/(?:nation\/[A-Z]{2}|diocese\/[a-z]{6}_[a-z]{2})(?:\?locale=[a-zA-Z0-9_]+)?$/ " , $ dataPath )
307
312
) {
308
- return LitSchema::EVENTS ;
313
+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: EVENTS ) : LitSchema::EVENTS ;
309
314
} elseif (
310
315
preg_match ("/\/data\/(?:(nation)\/[A-Z]{2}|(diocese)\/[a-z]{6}_[a-z]{2}|(widerregion)\/[A-Z][a-z]+)(?:\?locale=[a-zA-Z0-9_]+)?$/ " , $ dataPath , $ matches )
311
316
) {
@@ -325,9 +330,19 @@ private static function retrieveSchemaForCategory(string $category, ?string $dat
325
330
}
326
331
}
327
332
}
328
- return $ schema ;
333
+ return $ isVersionedDataPath ? preg_replace ($ versionedPattern , $ versionedReplacement , $ schema ) : $ schema ;
334
+ }
335
+ if ($ isVersionedDataPath ) {
336
+ $ versionedDataPath = preg_replace ($ versionedPattern , $ versionedReplacement , $ dataPath );
337
+ if (array_key_exists ($ versionedDataPath , Health::DATA_PATH_TO_SCHEMA )) {
338
+ $ tempSchemaPath = Health::DATA_PATH_TO_SCHEMA [ $ versionedDataPath ];
339
+ return preg_replace ($ versionedPattern , $ versionedReplacement , $ tempSchemaPath );
340
+ }
329
341
}
330
- return Health::DATA_PATH_TO_SCHEMA [ $ dataPath ];
342
+ if (array_key_exists ($ dataPath , Health::DATA_PATH_TO_SCHEMA )) {
343
+ return Health::DATA_PATH_TO_SCHEMA [ $ dataPath ];
344
+ }
345
+ return null ;
331
346
break ;
332
347
case 'sourceDataCheck ' :
333
348
if (preg_match ("/-i18n$/ " , $ dataPath )) {
0 commit comments