From 2933aabf82a145f298e6424c90056379e0ddd93d Mon Sep 17 00:00:00 2001 From: Dorian Merz <merz@ub.uni-leipzig.de> Date: Mon, 6 Apr 2020 15:17:00 +0200 Subject: [PATCH] refs #17140 [master-v5] VF% changes to RecordDriver ILS integration * uses IlsAwareTrait * uses IlsAwareDelegatorFactory --- module/finc/config/module.config.php | 17 +++ .../finc/src/finc/RecordDriver/SolrMarc.php | 118 +----------------- 2 files changed, 20 insertions(+), 115 deletions(-) diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php index 50143c8030a..587fd069aff 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -116,6 +116,23 @@ $config = [ 'solrlidondl' => 'finc\RecordDriver\SolrLidoNdl', 'solrdico' => 'finc\RecordDriver\SolrDico', ], + 'delegators' => [ + 'finc\RecordDriver\SolrMarc' => [ + 'VuFind\RecordDriver\IlsAwareDelegatorFactory', + ], + 'finc\RecordDriver\SolrMarcFinc' => [ + 'VuFind\RecordDriver\IlsAwareDelegatorFactory', + ], + 'finc\RecordDriver\SolrMarcFincPDA' => [ + 'VuFind\RecordDriver\IlsAwareDelegatorFactory', + ], + 'finc\RecordDriver\SolrMarcRemote' => [ + 'VuFind\RecordDriver\IlsAwareDelegatorFactory', + ], + 'finc\RecordDriver\SolrMarcRemoteFinc' => [ + 'VuFind\RecordDriver\IlsAwareDelegatorFactory', + ], + ] ], 'recordtab' => [ 'factories' => [ diff --git a/module/finc/src/finc/RecordDriver/SolrMarc.php b/module/finc/src/finc/RecordDriver/SolrMarc.php index 743a7c3559c..cc567699330 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarc.php +++ b/module/finc/src/finc/RecordDriver/SolrMarc.php @@ -29,7 +29,7 @@ */ namespace finc\RecordDriver; -use VuFind\Exception\ILS as ILSException; +use VuFind\RecordDriver\IlsAwareTrait; use VuFind\View\Helper\Root\RecordLink; use VuFind\XSLT\Processor as XSLTProcessor; @@ -45,6 +45,8 @@ use VuFind\XSLT\Processor as XSLTProcessor; */ class SolrMarc extends SolrDefault { + use IlsAwareTrait; + /** * MARC record. Access only via getMarcRecord() as this is initialized lazily. * @@ -52,27 +54,6 @@ class SolrMarc extends SolrDefault */ protected $lazyMarcRecord = null; - /** - * ILS connection - * - * @var \VuFind\ILS\Connection - */ - protected $ils = null; - - /** - * Hold logic - * - * @var \VuFind\ILS\Logic\Holds - */ - protected $holdLogic; - - /** - * Title hold logic - * - * @var \VuFind\ILS\Logic\TitleHolds - */ - protected $titleHoldLogic; - /** * Get access restriction notes for the record. * @@ -924,99 +905,6 @@ class SolrMarc extends SolrDefault return parent::getXML($format, $baseUrl, $recordLink); } - /** - * Attach an ILS connection and related logic to the driver - * - * @param \VuFind\ILS\Connection $ils ILS connection - * @param \VuFind\ILS\Logic\Holds $holdLogic Hold logic handler - * @param \VuFind\ILS\Logic\TitleHolds $titleHoldLogic Title hold logic handler - * - * @return void - */ - public function attachILS( - \VuFind\ILS\Connection $ils, - \VuFind\ILS\Logic\Holds $holdLogic, - \VuFind\ILS\Logic\TitleHolds $titleHoldLogic - ) { - $this->ils = $ils; - $this->holdLogic = $holdLogic; - $this->titleHoldLogic = $titleHoldLogic; - } - - /** - * Do we have an attached ILS connection? - * - * @return bool - */ - protected function hasILS() - { - return null !== $this->ils; - } - - /** - * Get an array of information about record holdings, obtained in real-time - * from the ILS. - * - * @return array - */ - public function getRealTimeHoldings() - { - return $this->hasILS() ? $this->holdLogic->getHoldings( - $this->getUniqueID(), - $this->getConsortialIDs() - ) : []; - } - - /** - * Get an array of information about record history, obtained in real-time - * from the ILS. - * - * @return array - */ - public function getRealTimeHistory() - { - // Get Acquisitions Data - if (!$this->hasILS()) { - return []; - } - try { - return $this->ils->getPurchaseHistory($this->getUniqueID()); - } catch (ILSException $e) { - return []; - } - } - - /** - * Get a link for placing a title level hold. - * - * @return mixed A url if a hold is possible, boolean false if not - */ - public function getRealTimeTitleHold() - { - if ($this->hasILS()) { - $biblioLevel = strtolower($this->getBibliographicLevel()); - if ("monograph" == $biblioLevel || strstr($biblioLevel, "part")) { - if ($this->ils->getTitleHoldsMode() != "disabled") { - return $this->titleHoldLogic->getHold($this->getUniqueID()); - } - } - } - - return false; - } - - /** - * Returns true if the record supports real-time AJAX status lookups. - * - * @return bool - */ - public function supportsAjaxStatus() - { - // as AJAX status lookups are done via the ILS AJAX status lookup support is - // only given if the ILS is available for this record - return $this->hasILS(); - } - /** * Get access to the raw File_MARC object. * -- GitLab