Skip to content
Snippets Groups Projects
Commit 79f8de22 authored by Demian Katz's avatar Demian Katz
Browse files

Switched to dependency injection for cleaner WorldCatIdentities/WorldCatTerms...

Switched to dependency injection for cleaner WorldCatIdentities/WorldCatTerms recommendation modules.
parent 42cb3195
No related merge requests found
......@@ -201,6 +201,18 @@ $config = array(
),
'recommend_plugin_manager' => array(
'abstract_factories' => array('VuFind\Recommend\PluginFactory'),
'factories' => array(
'worldcatidentities' => function ($sm) {
return new \VuFind\Recommend\WorldCatIdentities(
$sm->getServiceLocator()->get('VuFind\WorldCatUtils')
);
},
'worldcatterms' => function ($sm) {
return new \VuFind\Recommend\WorldCatTerms(
$sm->getServiceLocator()->get('VuFind\WorldCatUtils')
);
},
),
'invokables' => array(
'authorfacets' => 'VuFind\Recommend\AuthorFacets',
'authorinfo' => 'VuFind\Recommend\AuthorInfo',
......@@ -219,8 +231,6 @@ $config = array(
'summonresults' => 'VuFind\Recommend\SummonResults',
'switchtype' => 'VuFind\Recommend\SwitchType',
'topfacets' => 'VuFind\Recommend\TopFacets',
'worldcatidentities' => 'VuFind\Recommend\WorldCatIdentities',
'worldcatterms' => 'VuFind\Recommend\WorldCatTerms',
),
),
'recorddriver_plugin_manager' => array(
......
......@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/
namespace VuFind\Recommend;
use VuFind\Connection\WorldCatUtils;
/**
* WorldCatIdentities Recommendations Module
......@@ -38,11 +39,39 @@ namespace VuFind\Recommend;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/
class WorldCatIdentities extends AbstractSearchManagerAwareModule
class WorldCatIdentities implements RecommendInterface
{
/**
* Search results object
*
* @var \VuFind\Search\Base\Results
*/
protected $searchObject;
/**
* Configuration settings
*
* @var array
*/
protected $settings;
/**
* WorldCat utilities wrapper object.
*
* @var WorldCatUtils
*/
protected $worldCatUtils;
/**
* Constructor
*
* @param WorldCatUtils $wcu WorldCat utilities object
*/
public function __construct(WorldCatUtils $wcu)
{
$this->worldCatUtils = $wcu;
}
/**
* setConfig
*
......@@ -105,8 +134,6 @@ class WorldCatIdentities extends AbstractSearchManagerAwareModule
$lookfor = isset($search[0]['lookfor']) ? $search[0]['lookfor'] : '';
// Get terminology information:
return $this->getServiceLocator()->getServiceLocator()
->get('VuFind\WorldCatUtils')
->getRelatedIdentities($lookfor);
return $this->worldCatUtils->getRelatedIdentities($lookfor);
}
}
\ No newline at end of file
......@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/
namespace VuFind\Recommend;
use VuFind\Connection\WorldCatUtils;
/**
* WorldCatTerms Recommendations Module
......@@ -38,11 +39,39 @@ namespace VuFind\Recommend;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/
class WorldCatTerms extends AbstractSearchManagerAwareModule
class WorldCatTerms implements RecommendInterface
{
/**
* Search results object
*
* @var \VuFind\Search\Base\Results
*/
protected $searchObject;
/**
* Vocabulary to use.
*
* @var string
*/
protected $vocab = 'lcsh';
/**
* WorldCat utilities wrapper object.
*
* @var WorldCatUtils
*/
protected $worldCatUtils;
/**
* Constructor
*
* @param WorldCatUtils $wcu WorldCat utilities object
*/
public function __construct(WorldCatUtils $wcu)
{
$this->worldCatUtils = $wcu;
}
/**
* setConfig
*
......@@ -106,9 +135,7 @@ class WorldCatTerms extends AbstractSearchManagerAwareModule
$lookfor = isset($search[0]['lookfor']) ? $search[0]['lookfor'] : '';
// Get terminology information:
$wc = $this->getServiceLocator()->getServiceLocator()
->get('VuFind\WorldCatUtils');
$terms = $wc->getRelatedTerms($lookfor, $this->vocab);
$terms = $this->worldCatUtils->getRelatedTerms($lookfor, $this->vocab);
// Wipe out any empty or unexpected sections of the related terms array;
// this will make it easier to only display content in the template if
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment