diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatterFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatterFactory.php index 18916b07561e27f7c57d14bcc2db75370b9801c5..06986c02b0ad33c9138d6f3990fcad8595a22071 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatterFactory.php @@ -28,6 +28,9 @@ */ namespace VuFind\View\Helper\Root; +use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; + /** * Factory for record driver data formatting view helper * @@ -38,16 +41,31 @@ namespace VuFind\View\Helper\Root; * @link https://vufind.org/wiki/development:architecture:record_data_formatter * Wiki */ -class RecordDataFormatterFactory +class RecordDataFormatterFactory implements FactoryInterface { /** - * Create the helper. + * Create an object + * + * @param ContainerInterface $container Service manager + * @param string $requestedName Service being created + * @param null|array $options Extra options (optional) + * + * @return object * - * @return RecordDataFormatter + * @throws ServiceNotFoundException if unable to resolve the service. + * @throws ServiceNotCreatedException if an exception is raised when + * creating a service. + * @throws ContainerException if any other error occurs + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function __invoke() - { - $helper = new RecordDataFormatter(); + public function __invoke(ContainerInterface $container, $requestedName, + array $options = null + ) { + if (!empty($options)) { + throw new \Exception('Unexpected options sent to factory.'); + } + $helper = new $requestedName(); $helper->setDefaults( 'collection-info', [$this, 'getDefaultCollectionInfoSpecs'] ); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php index 43dc3c61741f37f86eb0027c4b4d371e2195520c..ef8b0d1c07ca0c83b2a8b5789c4645bfe67cf869 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/RecordDataFormatterTest.php @@ -130,7 +130,9 @@ class RecordDataFormatterTest extends \VuFindTest\Unit\ViewHelperTestCase { // Build the formatter: $factory = new RecordDataFormatterFactory(); - $formatter = $factory->__invoke(); + $formatter = $factory->__invoke( + $this->getServiceManager(), RecordDataFormatter::class + ); // Create a view object with a set of helpers: $helpers = $this->getViewHelpers(); diff --git a/module/VuFindTheme/Module.php b/module/VuFindTheme/Module.php index 15c58f47cc26b3d87568136b34e8bca46a2d20ee..ad5e28d571b4ed799f1a17f8eb2732ed1de8e678 100644 --- a/module/VuFindTheme/Module.php +++ b/module/VuFindTheme/Module.php @@ -89,10 +89,10 @@ class Module { return [ 'factories' => [ - 'headThemeResources' => + 'VuFindTheme\View\Helper\HeadThemeResources' => 'VuFindTheme\View\Helper\Factory::getHeadThemeResources', - 'imageLink' => 'VuFindTheme\View\Helper\Factory::getImageLink', - // We have to override the Zend helpers using canonical names: + 'VuFindTheme\View\Helper\ImageLink' => + 'VuFindTheme\View\Helper\Factory::getImageLink', 'Zend\View\Helper\HeadLink' => 'VuFindTheme\View\Helper\Factory::getHeadLink', 'Zend\View\Helper\HeadScript' => @@ -100,6 +100,10 @@ class Module 'Zend\View\Helper\InlineScript' => 'VuFindTheme\View\Helper\Factory::getInlineScript', ], + 'aliases' => [ + 'headThemeResources' => 'VuFindTheme\View\Helper\HeadThemeResources', + 'imageLink' => 'VuFindTheme\View\Helper\ImageLink', + ], ]; } diff --git a/themes/bootstrap3/theme.config.php b/themes/bootstrap3/theme.config.php index c8a8b85eae17db331592d45e3c2da4309e8cb7fe..158ab6d5f1b3b0a1d9a8d3d1ae7298e9d3fcf040 100644 --- a/themes/bootstrap3/theme.config.php +++ b/themes/bootstrap3/theme.config.php @@ -28,12 +28,17 @@ return [ 'favicon' => 'vufind-favicon.ico', 'helpers' => [ 'factories' => [ - 'flashmessages' => 'VuFind\View\Helper\Bootstrap3\Factory::getFlashmessages', - 'layoutClass' => 'VuFind\View\Helper\Bootstrap3\Factory::getLayoutClass', - 'recaptcha' => 'VuFind\View\Helper\Bootstrap3\Factory::getRecaptcha', + 'VuFind\View\Helper\Bootstrap3\Flashmessages' => 'VuFind\View\Helper\Bootstrap3\Factory::getFlashmessages', + 'VuFind\View\Helper\Bootstrap3\Highlight' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Bootstrap3\LayoutClass' => 'VuFind\View\Helper\Bootstrap3\Factory::getLayoutClass', + 'VuFind\View\Helper\Bootstrap3\Recaptcha' => 'VuFind\View\Helper\Bootstrap3\Factory::getRecaptcha', + 'VuFind\View\Helper\Bootstrap3\Search' => 'Zend\ServiceManager\Factory\InvokableFactory', ], - 'invokables' => [ + 'aliases' => [ + 'flashmessages' => 'VuFind\View\Helper\Bootstrap3\Flashmessages', 'highlight' => 'VuFind\View\Helper\Bootstrap3\Highlight', + 'layoutClass' => 'VuFind\View\Helper\Bootstrap3\LayoutClass', + 'recaptcha' => 'VuFind\View\Helper\Bootstrap3\Recaptcha', 'search' => 'VuFind\View\Helper\Bootstrap3\Search' ] ] diff --git a/themes/root/theme.config.php b/themes/root/theme.config.php index 01a2578a348d4a9d9947e8751968ae6eb6b57ac4..4a27359a56425bae4b3a5fef2f0685e64f22fe5b 100644 --- a/themes/root/theme.config.php +++ b/themes/root/theme.config.php @@ -3,62 +3,116 @@ return [ 'extends' => false, 'helpers' => [ 'factories' => [ - 'accountCapabilities' => 'VuFind\View\Helper\Root\Factory::getAccountCapabilities', - 'addThis' => 'VuFind\View\Helper\Root\Factory::getAddThis', - 'alphabrowse' => 'VuFind\View\Helper\Root\Factory::getAlphaBrowse', - 'auth' => 'VuFind\View\Helper\Root\Factory::getAuth', - 'authorNotes' => 'VuFind\View\Helper\Root\Factory::getAuthorNotes', - 'cart' => 'VuFind\View\Helper\Root\Factory::getCart', - 'citation' => 'VuFind\View\Helper\Root\Factory::getCitation', - 'dateTime' => 'VuFind\View\Helper\Root\Factory::getDateTime', - 'displayLanguageOption' => 'VuFind\View\Helper\Root\Factory::getDisplayLanguageOption', - 'export' => 'VuFind\View\Helper\Root\Factory::getExport', - 'feedback' => 'VuFind\View\Helper\Root\Factory::getFeedback', - 'flashmessages' => 'VuFind\View\Helper\Root\Factory::getFlashmessages', - 'geocoords' => 'VuFind\View\Helper\Root\Factory::getGeoCoords', - 'googleanalytics' => 'VuFind\View\Helper\Root\Factory::getGoogleAnalytics', - 'helpText' => 'VuFind\View\Helper\Root\Factory::getHelpText', - 'historylabel' => 'VuFind\View\Helper\Root\Factory::getHistoryLabel', - 'ils' => 'VuFind\View\Helper\Root\Factory::getIls', - 'jsTranslations' => 'VuFind\View\Helper\Root\Factory::getJsTranslations', - 'keepAlive' => 'VuFind\View\Helper\Root\Factory::getKeepAlive', - 'permission' => 'VuFind\View\Helper\Root\Factory::getPermission', - 'proxyUrl' => 'VuFind\View\Helper\Root\Factory::getProxyUrl', - 'openUrl' => 'VuFind\View\Helper\Root\Factory::getOpenUrl', - 'piwik' => 'VuFind\View\Helper\Root\Factory::getPiwik', - 'recaptcha' => 'VuFind\View\Helper\Root\Factory::getRecaptcha', - 'record' => 'VuFind\View\Helper\Root\Factory::getRecord', - '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', - 'searchOptions' => 'VuFind\View\Helper\Root\Factory::getSearchOptions', - 'searchParams' => 'VuFind\View\Helper\Root\Factory::getSearchParams', - 'searchTabs' => 'VuFind\View\Helper\Root\Factory::getSearchTabs', - 'summaries' => 'VuFind\View\Helper\Root\Factory::getSummaries', - 'syndeticsPlus' => 'VuFind\View\Helper\Root\Factory::getSyndeticsPlus', - 'systemEmail' => 'VuFind\View\Helper\Root\Factory::getSystemEmail', - 'userlist' => 'VuFind\View\Helper\Root\Factory::getUserList', - 'usertags' => 'VuFind\View\Helper\Root\Factory::getUserTags', + 'VuFind\View\Helper\Root\AccountCapabilities' => 'VuFind\View\Helper\Root\Factory::getAccountCapabilities', + 'VuFind\View\Helper\Root\AddEllipsis' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\AddThis' => 'VuFind\View\Helper\Root\Factory::getAddThis', + 'VuFind\View\Helper\Root\AlphaBrowse' => 'VuFind\View\Helper\Root\Factory::getAlphaBrowse', + 'VuFind\View\Helper\Root\Auth' => 'VuFind\View\Helper\Root\Factory::getAuth', + 'VuFind\View\Helper\Root\AuthorNotes' => 'VuFind\View\Helper\Root\Factory::getAuthorNotes', + 'VuFind\View\Helper\Root\Browse' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\Cart' => 'VuFind\View\Helper\Root\Factory::getCart', + 'VuFind\View\Helper\Root\Citation' => 'VuFind\View\Helper\Root\Factory::getCitation', + 'VuFind\View\Helper\Root\Context' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\CurrentPath' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\DateTime' => 'VuFind\View\Helper\Root\Factory::getDateTime', + 'VuFind\View\Helper\Root\DisplayLanguageOption' => 'VuFind\View\Helper\Root\Factory::getDisplayLanguageOption', + 'VuFind\View\Helper\Root\Export' => 'VuFind\View\Helper\Root\Factory::getExport', + 'VuFind\View\Helper\Root\Feedback' => 'VuFind\View\Helper\Root\Factory::getFeedback', + 'VuFind\View\Helper\Root\Flashmessages' => 'VuFind\View\Helper\Root\Factory::getFlashmessages', + 'VuFind\View\Helper\Root\GeoCoords' => 'VuFind\View\Helper\Root\Factory::getGeoCoords', + 'VuFind\View\Helper\Root\GoogleAnalytics' => 'VuFind\View\Helper\Root\Factory::getGoogleAnalytics', + 'VuFind\View\Helper\Root\HelpText' => 'VuFind\View\Helper\Root\Factory::getHelpText', + 'VuFind\View\Helper\Root\Highlight' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\HistoryLabel' => 'VuFind\View\Helper\Root\Factory::getHistoryLabel', + 'VuFind\View\Helper\Root\Ils' => 'VuFind\View\Helper\Root\Factory::getIls', + 'VuFind\View\Helper\Root\JsTranslations' => 'VuFind\View\Helper\Root\Factory::getJsTranslations', + 'VuFind\View\Helper\Root\KeepAlive' => 'VuFind\View\Helper\Root\Factory::getKeepAlive', + 'VuFind\View\Helper\Root\LocalizedNumber' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\OpenUrl' => 'VuFind\View\Helper\Root\Factory::getOpenUrl', + 'VuFind\View\Helper\Root\Permission' => 'VuFind\View\Helper\Root\Factory::getPermission', + 'VuFind\View\Helper\Root\Piwik' => 'VuFind\View\Helper\Root\Factory::getPiwik', + 'VuFind\View\Helper\Root\Printms' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\ProxyUrl' => 'VuFind\View\Helper\Root\Factory::getProxyUrl', + 'VuFind\View\Helper\Root\Recaptcha' => 'VuFind\View\Helper\Root\Factory::getRecaptcha', + 'VuFind\View\Helper\Root\Recommend' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\Record' => 'VuFind\View\Helper\Root\Factory::getRecord', + 'VuFind\View\Helper\Root\RecordDataFormatter' => 'VuFind\View\Helper\Root\RecordDataFormatterFactory', + 'VuFind\View\Helper\Root\RecordLink' => 'VuFind\View\Helper\Root\Factory::getRecordLink', + 'VuFind\View\Helper\Root\Related' => 'VuFind\View\Helper\Root\Factory::getRelated', + 'VuFind\View\Helper\Root\RenderArray' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\ResultFeed' => 'VuFind\View\Helper\Root\Factory::getResultFeed', + 'VuFind\View\Helper\Root\SafeMoneyFormat' => 'VuFind\View\Helper\Root\Factory::getSafeMoneyFormat', + 'VuFind\View\Helper\Root\SearchBox' => 'VuFind\View\Helper\Root\Factory::getSearchBox', + 'VuFind\View\Helper\Root\SearchMemory' => 'VuFind\View\Helper\Root\Factory::getSearchMemory', + 'VuFind\View\Helper\Root\SearchOptions' => 'VuFind\View\Helper\Root\Factory::getSearchOptions', + 'VuFind\View\Helper\Root\SearchParams' => 'VuFind\View\Helper\Root\Factory::getSearchParams', + 'VuFind\View\Helper\Root\SearchTabs' => 'VuFind\View\Helper\Root\Factory::getSearchTabs', + 'VuFind\View\Helper\Root\SortFacetList' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\Summaries' => 'VuFind\View\Helper\Root\Factory::getSummaries', + 'VuFind\View\Helper\Root\Summon' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\SyndeticsPlus' => 'VuFind\View\Helper\Root\Factory::getSyndeticsPlus', + 'VuFind\View\Helper\Root\SystemEmail' => 'VuFind\View\Helper\Root\Factory::getSystemEmail', + 'VuFind\View\Helper\Root\TransEsc' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\Translate' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\Truncate' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'VuFind\View\Helper\Root\UserList' => 'VuFind\View\Helper\Root\Factory::getUserList', + 'VuFind\View\Helper\Root\UserTags' => 'VuFind\View\Helper\Root\Factory::getUserTags', ], - 'invokables' => [ + 'aliases' => [ + 'accountCapabilities' => 'VuFind\View\Helper\Root\AccountCapabilities', 'addEllipsis' => 'VuFind\View\Helper\Root\AddEllipsis', + 'addThis' => 'VuFind\View\Helper\Root\AddThis', + 'alphabrowse' => 'VuFind\View\Helper\Root\AlphaBrowse', + 'auth' => 'VuFind\View\Helper\Root\Auth', + 'authorNotes' => 'VuFind\View\Helper\Root\AuthorNotes', 'browse' => 'VuFind\View\Helper\Root\Browse', + 'cart' => 'VuFind\View\Helper\Root\Cart', + 'citation' => 'VuFind\View\Helper\Root\Citation', 'context' => 'VuFind\View\Helper\Root\Context', 'currentPath' => 'VuFind\View\Helper\Root\CurrentPath', + 'dateTime' => 'VuFind\View\Helper\Root\DateTime', + 'displayLanguageOption' => 'VuFind\View\Helper\Root\DisplayLanguageOption', + 'export' => 'VuFind\View\Helper\Root\Export', + 'feedback' => 'VuFind\View\Helper\Root\Feedback', + 'flashmessages' => 'VuFind\View\Helper\Root\Flashmessages', + 'geocoords' => 'VuFind\View\Helper\Root\GeoCoords', + 'googleanalytics' => 'VuFind\View\Helper\Root\GoogleAnalytics', + 'helpText' => 'VuFind\View\Helper\Root\HelpText', 'highlight' => 'VuFind\View\Helper\Root\Highlight', + 'historylabel' => 'VuFind\View\Helper\Root\HistoryLabel', + 'ils' => 'VuFind\View\Helper\Root\Ils', + 'jsTranslations' => 'VuFind\View\Helper\Root\JsTranslations', + 'keepAlive' => 'VuFind\View\Helper\Root\KeepAlive', 'localizedNumber' => 'VuFind\View\Helper\Root\LocalizedNumber', + 'openUrl' => 'VuFind\View\Helper\Root\OpenUrl', + 'permission' => 'VuFind\View\Helper\Root\Permission', + 'piwik' => 'VuFind\View\Helper\Root\Piwik', 'printms' => 'VuFind\View\Helper\Root\Printms', + 'proxyUrl' => 'VuFind\View\Helper\Root\ProxyUrl', + 'recaptcha' => 'VuFind\View\Helper\Root\Recaptcha', 'recommend' => 'VuFind\View\Helper\Root\Recommend', + 'record' => 'VuFind\View\Helper\Root\Record', + 'recordDataFormatter' => 'VuFind\View\Helper\Root\RecordDataFormatter', + 'recordLink' => 'VuFind\View\Helper\Root\RecordLink', + 'related' => 'VuFind\View\Helper\Root\Related', 'renderArray' => 'VuFind\View\Helper\Root\RenderArray', + 'resultfeed' => 'VuFind\View\Helper\Root\ResultFeed', + 'safeMoneyFormat' => 'VuFind\View\Helper\Root\SafeMoneyFormat', + 'searchMemory' => 'VuFind\View\Helper\Root\SearchMemory', + 'searchOptions' => 'VuFind\View\Helper\Root\SearchOptions', + 'searchParams' => 'VuFind\View\Helper\Root\SearchParams', + 'searchTabs' => 'VuFind\View\Helper\Root\SearchTabs', + 'searchbox' => 'VuFind\View\Helper\Root\SearchBox', 'sortFacetList' => 'VuFind\View\Helper\Root\SortFacetList', + 'summaries' => 'VuFind\View\Helper\Root\Summaries', 'summon' => 'VuFind\View\Helper\Root\Summon', + 'syndeticsPlus' => 'VuFind\View\Helper\Root\SyndeticsPlus', + 'systemEmail' => 'VuFind\View\Helper\Root\SystemEmail', 'transEsc' => 'VuFind\View\Helper\Root\TransEsc', 'translate' => 'VuFind\View\Helper\Root\Translate', 'truncate' => 'VuFind\View\Helper\Root\Truncate', + 'userlist' => 'VuFind\View\Helper\Root\UserList', + 'usertags' => 'VuFind\View\Helper\Root\UserTags', ] ], ];