Skip to content

Commit

Permalink
ensure diocesan calendar_id is valid for given national calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Nov 2, 2024
1 parent 275a2f8 commit ee6a2f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion php/src/LitSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,19 @@ private function isValidNationalCalendar($value)
*/
private function isValidDiocesanCalendar($value)
{
return $value !== "" && $this->Metadata !== null && in_array($value, $this->Metadata["diocesan_calendars_keys"]);
if ($this->NationalCalendar === null) {
return $value !== "" && $this->Metadata !== null && in_array($value, $this->Metadata["diocesan_calendars_keys"]);
} else {
if (null === $this->Metadata) {
return false;
}
$DiocesanCalendarsForNation = array_values(array_filter(
$this->Metadata["diocesan_calendars"],
fn ($calendar) => $calendar["nation"] === $this->NationalCalendar
));
$DiocesanCalendarIds = array_column($DiocesanCalendarsForNation, "calendar_id");
return $value !== "" && in_array($value, $DiocesanCalendarIds);
}
}

/**
Expand Down

0 comments on commit ee6a2f2

Please sign in to comment.