Skip to content

Commit

Permalink
determine dataPath for calendar i18n source checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Nov 29, 2024
1 parent f58e000 commit e16f109
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Health.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@ private function executeValidation(object $validation, ConnectionInterface $to)
$pathForSchema = $validation->validate;
if (property_exists($validation, 'sourceFolder')) {
$dataPath = rtrim($validation->sourceFolder, '/');
$matches = null;
if (preg_match("/^(wider-region|national-calendar|diocesan-calendar)-([A-Z][a-z]+)-i18n$/i", $validation->validate, $matches)) {
switch ($matches[1]) {
case 'wider-region':
$dataPath = strtr(
JsonData::WIDER_REGIONS_I18N_FOLDER,
['{wider_region}' => $matches[2]]
);
break;
case 'national-calendar':
$dataPath = strtr(
JsonData::NATIONAL_CALENDARS_I18N_FOLDER,
['{nation}' => $matches[2]]
);
break;
case 'diocesan-calendar':
$diocese = array_values(array_filter(self::$metadata->litcal_metadata->diocesan_calendars, fn ($el) => $el->calendar_id === $matches[2]));
$nation = $diocese[0]->nation;
$dataPath = strtr(
JsonData::DIOCESAN_CALENDARS_I18N_FOLDER,
['{diocese}' => $matches[2]],
['{nation}' => $nation]
);
break;
}
}
} else {
if (property_exists($validation, 'sourceFile')) {
$dataPath = $validation->sourceFile;
Expand Down

0 comments on commit e16f109

Please sign in to comment.