diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php b/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php index 0d1711aed8e3b59a324f877d34dfb2fa9a9f5a28..ffd937ee95f0ad2c0a86e7594bbc668e0764d16c 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php @@ -26,7 +26,7 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\View\Helper\Root; -use Zend\View\Helper\AbstractHelper; +use DOMDocument, Zend\View\Helper\AbstractHelper; /** * Author Notes view helper @@ -206,4 +206,17 @@ abstract class AbstractSyndetics extends AbstractHelper { return $this->loadSyndetics($id, true); } + + /** + * Turn an XML response into a DOMDocument object. + * + * @param string $xml XML to load. + * + * @return DOMDocument|bool Document on success, false on failure. + */ + protected function xmlToDOMDocument($xml) + { + $dom = new DOMDocument(); + return $dom->loadXML($xml) ? $dom : false; + } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php b/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php index 83d43f20ef072d5bec9cdb4093ee3a01b4962928..224821c38b23f80686353e4a36fcdb3201b88c0b 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php @@ -26,7 +26,6 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\View\Helper\Root; -use DOMDocument; /** * Author Notes view helper @@ -93,7 +92,7 @@ class AuthorNotes extends AbstractSyndetics } // Test XML Response - if (!($xmldoc = DOMDocument::loadXML($result->getBody()))) { + if (!($xmldoc = $this->xmlToDOMDocument($result->getBody()))) { throw new \Exception('Invalid XML'); } @@ -109,7 +108,7 @@ class AuthorNotes extends AbstractSyndetics } // Test XML Response - $xmldoc2 = DOMDocument::loadXML($result2->getBody()); + $xmldoc2 = $this->xmlToDOMDocument($result2->getBody()); if (!$xmldoc2) { throw new \Exception('Invalid XML'); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php b/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php index b9665ebe10bfa3bd07cafc5c1f365e4cd481e8e3..46f9fcfdacaddf2af4751ce335588653071ea12b 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php @@ -26,7 +26,6 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\View\Helper\Root; -use DOMDocument; /** * Excerpt view helper @@ -94,7 +93,7 @@ class Excerpt extends AbstractSyndetics } // Test XML Response - if (!($xmldoc = DOMDocument::loadXML($result->getBody()))) { + if (!($xmldoc = $this->xmlToDOMDocument($result->getBody()))) { throw new \Exception('Invalid XML'); } @@ -110,7 +109,7 @@ class Excerpt extends AbstractSyndetics } // Test XML Response - $xmldoc2 = DOMDocument::loadXML($result2->getBody()); + $xmldoc2 = $this->xmlToDOMDocument($result2->getBody()); if (!$xmldoc2) { throw new \Exception('Invalid XML'); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php b/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php index 54f736e2af14d29972f1542a0637d42a7e670b31..472bcf8d5bb265bffa0d991b6915101640d14b74 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php @@ -26,7 +26,7 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\View\Helper\Root; -use DOMDocument, ZendService\Amazon\Amazon; +use ZendService\Amazon\Amazon; /** * Reviews view helper @@ -341,7 +341,7 @@ class Reviews extends AbstractSyndetics implements \Zend\Log\LoggerAwareInterfac } // Test XML Response - if (!($xmldoc = DOMDocument::loadXML($result->getBody()))) { + if (!($xmldoc = $this->xmlToDOMDocument($result->getBody()))) { throw new \Exception('Invalid XML'); } @@ -357,7 +357,7 @@ class Reviews extends AbstractSyndetics implements \Zend\Log\LoggerAwareInterfac } // Test XML Response - $xmldoc2 = DOMDocument::loadXML($result2->getBody()); + $xmldoc2 = $this->xmlToDOMDocument($result2->getBody()); if (!$xmldoc2) { throw new \Exception('Invalid XML'); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php b/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php index 884a70709c6fea515a798cdf2550249fe4dc0a79..66972ec1840104a36dc6bf9137aa6b07ffdc1216 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php @@ -26,7 +26,6 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\View\Helper\Root; -use DOMDocument; /** * Video clip view helper @@ -93,7 +92,7 @@ class VideoClips extends AbstractSyndetics } // Test XML Response - if (!($xmldoc = DOMDocument::loadXML($result->getBody()))) { + if (!($xmldoc = $this->xmlToDOMDocument($result->getBody()))) { throw new \Exception('Invalid XML'); } @@ -109,7 +108,7 @@ class VideoClips extends AbstractSyndetics } // Test XML Response - $xmldoc2 = DOMDocument::loadXML($result2->getBody()); + $xmldoc2 = $this->xmlToDOMDocument($result2->getBody()); if (!$xmldoc2) { throw new \Exception('Invalid XML'); }