@@ -278,34 +278,39 @@ public function __construct()
278278 */
279279 private static function retrieveSchemaForCategory (string $ category , ?string $ dataPath = null ): ?string
280280 {
281+ $ versionedPattern = "/\/api\/v[4-9]\// " ;
282+ $ versionedReplacement = "/api/dev/ " ;
283+ $ isVersionedDataPath = preg_match ($ versionedPattern , $ dataPath ) !== false ;
281284 switch ($ category ) {
282285 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+ }
283293 if (array_key_exists ($ dataPath , Health::DATA_PATH_TO_SCHEMA )) {
284294 return Health::DATA_PATH_TO_SCHEMA [ $ dataPath ];
285295 }
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- }
291296 return null ;
292297 case 'nationalcalendar ' :
293- return LitSchema::NATIONAL ;
298+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: NATIONAL ) : LitSchema::NATIONAL ;
294299 case 'diocesancalendar ' :
295- return LitSchema::DIOCESAN ;
300+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: DIOCESAN ) : LitSchema::DIOCESAN ;
296301 case 'widerregioncalendar ' :
297- return LitSchema::WIDERREGION ;
302+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: WIDERREGION ) : LitSchema::WIDERREGION ;
298303 case 'propriumdesanctis ' :
299- return LitSchema::PROPRIUMDESANCTIS ;
304+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: PROPRIUMDESANCTIS ) : LitSchema::PROPRIUMDESANCTIS ;
300305 case 'resourceDataCheck ' :
301306 if (
302307 preg_match ("/\/missals\/[_A-Z0-9]+$/ " , $ dataPath )
303308 ) {
304- return LitSchema::PROPRIUMDESANCTIS ;
309+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: PROPRIUMDESANCTIS ) : LitSchema::PROPRIUMDESANCTIS ;
305310 } elseif (
306311 preg_match ("/\/events\/(?:nation\/[A-Z]{2}|diocese\/[a-z]{6}_[a-z]{2})(?:\?locale=[a-zA-Z0-9_]+)?$/ " , $ dataPath )
307312 ) {
308- return LitSchema::EVENTS ;
313+ return $ isVersionedDataPath ? preg_replace ( $ versionedPattern , $ versionedReplacement , LitSchema:: EVENTS ) : LitSchema::EVENTS ;
309314 } elseif (
310315 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 )
311316 ) {
@@ -325,9 +330,19 @@ private static function retrieveSchemaForCategory(string $category, ?string $dat
325330 }
326331 }
327332 }
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+ }
329341 }
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 ;
331346 break ;
332347 case 'sourceDataCheck ' :
333348 if (preg_match ("/-i18n$/ " , $ dataPath )) {
0 commit comments