Skip to content

Commit

Permalink
#21372
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Jan 11, 2023
1 parent b2d426a commit bf8f64f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/aksearchExt/Alma.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,38 @@ static public function parseDateStatic($date, $withTime = false) {
throw new \Exception("Invalid date: $date");
}
}


/**
* We have to override the base method to fetch the values from our ALMA config.
*
* https://redmine.acdh.oeaw.ac.at/issues/21372
* @param type $patron
* @return type
*/
public function getPickupLocations($patron)
{
// Variable for returning
$filteredPul = null;

// Get pickup locations from Alma
$pul = parent::getPickupLocations($patron);

// Get config "validPickupLocations" and check if it is set
$validPulS = $this->config['Holds']['validPickupLocations'] ?? null ?: null;
if ($validPulS) {
// Convert config "validPickupLocations" to array
$validPul = preg_split('/\s*,\s*/', $validPulS);

// Filter valid pickup locations
$filteredPul = array_filter($pul,
function($p) use ($validPul) {
return in_array($p['locationID'], $validPul);
}
);
}

// Return result (resets the array keys with array_values)
return ($filteredPul) ? array_values($filteredPul) : $pul;
}
}

0 comments on commit bf8f64f

Please sign in to comment.