diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php index fad1fa487327eaabed3eb845b184cacc13d1a270..efccfd753eabdc347d519dcbad74da0ba57a7f57 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php @@ -446,6 +446,20 @@ class Factory ); } + /** + * Construct the ResultFeed helper. + * + * @param ServiceManager $sm Service manager. + * + * @return ResultFeed + */ + public static function getResultFeed(ServiceManager $sm) + { + $helper = new ResultFeed(); + $helper->registerExtensions($sm); + return $helper; + } + /** * Construct the SafeMoneyFormat helper. * diff --git a/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php index c4039d3d9f2cdc2363f99be0e3b398b6b3b4a5d0..a8665fa27f970b819e2f3d081f9d9b064837e3c8 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/ResultFeed.php @@ -31,6 +31,7 @@ use DateTime; use VuFind\I18n\Translator\TranslatorAwareInterface; use Zend\Feed\Writer\Feed; use Zend\Feed\Writer\Writer as FeedWriter; +use Zend\ServiceManager\ServiceManager; use Zend\View\Helper\AbstractHelper; /** @@ -66,26 +67,28 @@ class ResultFeed extends AbstractHelper implements TranslatorAwareInterface } /** - * Set up custom extensions. + * Set up custom extensions (should be called by factory). + * + * @param ServiceManager $sm Service manager. * * @return void */ - protected function registerExtensions() + public function registerExtensions(ServiceManager $sm) { - $manager = new \Zend\Feed\Writer\ExtensionPluginManager(); + $manager = new \Zend\Feed\Writer\ExtensionPluginManager($sm); $manager->setInvokableClass( - 'dublincorerendererentry', + 'DublinCore\Renderer\Entry', 'VuFind\Feed\Writer\Extension\DublinCore\Renderer\Entry' ); $manager->setInvokableClass( - 'dublincoreentry', 'VuFind\Feed\Writer\Extension\DublinCore\Entry' + 'DublinCore\Entry', 'VuFind\Feed\Writer\Extension\DublinCore\Entry' ); $manager->setInvokableClass( - 'opensearchrendererfeed', + 'OpenSearch\Renderer\Feed', 'VuFind\Feed\Writer\Extension\OpenSearch\Renderer\Feed' ); $manager->setInvokableClass( - 'opensearchfeed', 'VuFind\Feed\Writer\Extension\OpenSearch\Feed' + 'OpenSearch\Feed', 'VuFind\Feed\Writer\Extension\OpenSearch\Feed' ); FeedWriter::setExtensionManager($manager); FeedWriter::registerExtension('OpenSearch'); @@ -103,8 +106,6 @@ class ResultFeed extends AbstractHelper implements TranslatorAwareInterface */ public function __invoke($results, $currentPath = null) { - $this->registerExtensions(); - // Determine base URL if not already provided: if (is_null($currentPath)) { $currentPath = $this->getView()->plugin('currentpath')->__invoke(); diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php index e93e8f271575bbb3d6c82f1c3d7ee73024e43825..313ce64da8526d34ee30e3a88325cfb1ef5cfa2f 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/View/Helper/Root/ResultFeedTest.php @@ -123,6 +123,7 @@ class ResultFeedTest extends \VuFindTest\Unit\ViewHelperTestCase $results->getParams()->initFromRequest($request); $helper = new ResultFeed(); + $helper->registerExtensions($this->getServiceManager()); $helper->setTranslator($this->getMockTranslator()); $helper->setView($this->getPhpRenderer($this->getPlugins())); $feed = $helper->__invoke($results, '/test/path'); diff --git a/themes/root/theme.config.php b/themes/root/theme.config.php index 702072f5edf862f63b316f2c84b94734b2397bda..01a2578a348d4a9d9947e8751968ae6eb6b57ac4 100644 --- a/themes/root/theme.config.php +++ b/themes/root/theme.config.php @@ -31,6 +31,7 @@ return [ 'recordDataFormatter' => 'VuFind\View\Helper\Root\RecordDataFormatterFactory', 'recordLink' => 'VuFind\View\Helper\Root\Factory::getRecordLink', 'related' => 'VuFind\View\Helper\Root\Factory::getRelated', + 'resultfeed' => 'VuFind\View\Helper\Root\Factory::getResultFeed', 'safeMoneyFormat' => 'VuFind\View\Helper\Root\Factory::getSafeMoneyFormat', 'searchbox' => 'VuFind\View\Helper\Root\Factory::getSearchBox', 'searchMemory' => 'VuFind\View\Helper\Root\Factory::getSearchMemory', @@ -53,7 +54,6 @@ return [ 'printms' => 'VuFind\View\Helper\Root\Printms', 'recommend' => 'VuFind\View\Helper\Root\Recommend', 'renderArray' => 'VuFind\View\Helper\Root\RenderArray', - 'resultfeed' => 'VuFind\View\Helper\Root\ResultFeed', 'sortFacetList' => 'VuFind\View\Helper\Root\SortFacetList', 'summon' => 'VuFind\View\Helper\Root\Summon', 'transEsc' => 'VuFind\View\Helper\Root\TransEsc',