diff --git a/module/finc/src/finc/Controller/AmslResourceController.php b/module/finc/src/finc/Controller/AmslResourceController.php index 278f3fd14af3da3584ccbb179ebb853cc92c43d1..cf187741d7a47407cd8f781d4542b84c638d39a2 100644 --- a/module/finc/src/finc/Controller/AmslResourceController.php +++ b/module/finc/src/finc/Controller/AmslResourceController.php @@ -78,6 +78,13 @@ class AmslResourceController extends AbstractBase */ protected $baseUrl; + /** + * mapping of resource labels to be re-written for the query string + * + * @var array | null + */ + protected $resourceMapping; + /** * Constructor * @@ -91,13 +98,15 @@ class AmslResourceController extends AbstractBase ServiceLocatorInterface $sm, \Zend\Config\Config $config, \VuFindHttp\HttpService $httpClient, - \VuFind\Cache\Manager $cacheManager = null + \VuFind\Cache\Manager $cacheManager = null, + array $resourceMapping = null ) { parent::__construct($sm); $this->config = $config; $this->apiConfig = $config->API; $this->httpClient = $httpClient; $this->cacheManager = $cacheManager; + $this->resourceMapping = $resourceMapping; } /** @@ -265,16 +274,10 @@ class AmslResourceController extends AbstractBase } if(!empty($mapping->show_link) && !empty($source[$mapping->sub_key])) { - $misspelled = $this->config->get('MisspelledResources'); + $searchTerm = $source[$mapping->sub_key]; - if (!empty($misspelled)) { - foreach ($misspelled as $wrongLabel => $rightLabel) { - if (strpos($searchTerm, $wrongLabel) !== false) { - $searchTerm = $rightLabel; - break; - } - } - } + // map the source label to the correct SOLR search term + $searchTerm = $this->resourceMapping[$searchTerm] ?? $searchTerm; if (!$this->baseUrl) { $urlHelper = $this->getViewRenderer()->plugin('url'); diff --git a/module/finc/src/finc/Controller/AmslResourceControllerFactory.php b/module/finc/src/finc/Controller/AmslResourceControllerFactory.php index 92f8b637cc5f0baaf6062652ec17f75b2f5a46e0..a0b5134d6a8704fcc9f3dab7ed6b914c3c875d08 100644 --- a/module/finc/src/finc/Controller/AmslResourceControllerFactory.php +++ b/module/finc/src/finc/Controller/AmslResourceControllerFactory.php @@ -2,6 +2,7 @@ namespace finc\Controller; use Psr\Container\ContainerInterface; +use VuFind\Config\YamlReader; use Zend\ServiceManager\ServiceLocatorInterface; class AmslResourceControllerFactory @@ -13,11 +14,13 @@ class AmslResourceControllerFactory */ public function __invoke(ContainerInterface $container) { + $reader = $container->get('VuFind\YamlReader'); return new AmslResourceController( $container, $container->get('VuFind\Config\PluginManager')->get('Amsl'), $container->get('VuFindHttp\HttpService'), - $container->get('VuFind\Cache\Manager') + $container->get('VuFind\Cache\Manager'), + $reader->get('AmslResourceMapping.yaml') ); } } \ No newline at end of file