Skip to content

Commit

Permalink
create updateSettingsBasedOn... methods
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Jan 23, 2022
1 parent 3319645 commit 3b3822c
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions includes/LitCalAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,7 @@ private function initParameterData() {
}
}


private function loadLocalCalendarData() : void {
if( $this->LitSettings->DiocesanCalendar !== null ){
//since a Diocesan calendar is being requested, we need to retrieve the JSON data
//first we need to discover the path, so let's retrieve our index file
if( file_exists( "nations/index.json" ) ){
$this->GeneralIndex = json_decode( file_get_contents( "nations/index.json" ) );
if( property_exists( $this->GeneralIndex, $this->LitSettings->DiocesanCalendar ) ){
$diocesanDataFile = $this->GeneralIndex->{$this->LitSettings->DiocesanCalendar}->path;
$this->LitSettings->NationalCalendar = $this->GeneralIndex->{$this->LitSettings->DiocesanCalendar}->nation;
if( file_exists( $diocesanDataFile ) ){
$this->DiocesanData = json_decode( file_get_contents( $diocesanDataFile ) );
}
}
}
}

private function updateSettingsBasedOnNationalCalendar() : void {
if( $this->LitSettings->NationalCalendar !== null ) {
switch( $this->LitSettings->NationalCalendar ) {
case 'VATICAN':
Expand All @@ -159,7 +143,9 @@ private function loadLocalCalendarData() : void {
break;
}
}
}

private function updateSettingsBasedOnDiocesanCalendar() : void {
if( $this->LitSettings->DiocesanCalendar !== null && $this->DiocesanData !== null ) {
if( property_exists( $this->DiocesanData, "Overrides" ) ) {
foreach( $this->DiocesanData->Overrides as $key => $value ) {
Expand All @@ -185,6 +171,27 @@ private function loadLocalCalendarData() : void {
}
}


private function loadLocalCalendarData() : void {
if( $this->LitSettings->DiocesanCalendar !== null ){
//since a Diocesan calendar is being requested, we need to retrieve the JSON data
//first we need to discover the path, so let's retrieve our index file
if( file_exists( "nations/index.json" ) ){
$this->GeneralIndex = json_decode( file_get_contents( "nations/index.json" ) );
if( property_exists( $this->GeneralIndex, $this->LitSettings->DiocesanCalendar ) ){
$diocesanDataFile = $this->GeneralIndex->{$this->LitSettings->DiocesanCalendar}->path;
$this->LitSettings->NationalCalendar = $this->GeneralIndex->{$this->LitSettings->DiocesanCalendar}->nation;
if( file_exists( $diocesanDataFile ) ){
$this->DiocesanData = json_decode( file_get_contents( $diocesanDataFile ) );
}
}
}
}

$this->updateSettingsBasedOnNationalCalendar();
$this->updateSettingsBasedOnDiocesanCalendar();
}

private function cacheFileIsAvailable() : bool {
$cacheFilePath = "engineCache/v" . str_replace( ".", "_", self::API_VERSION ) . "/";
$cacheFileName = md5( serialize( $this->LitSettings) ) . $this->CacheDuration . "." . strtolower( $this->LitSettings->ReturnType );
Expand Down

0 comments on commit 3b3822c

Please sign in to comment.