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

Adjusted SyndeticsPlus view helper so that configuration is injected rather than statically loaded.

parent 1740b0c0
No related merge requests found
......@@ -26,7 +26,6 @@
* @link http://vufind.org Main Site
*/
namespace VuFind\View\Helper\Root;
use VuFind\Config\Reader as ConfigReader, Zend\View\Helper\AbstractHelper;
/**
* SyndeticsPlus view helper
......@@ -37,19 +36,26 @@ use VuFind\Config\Reader as ConfigReader, Zend\View\Helper\AbstractHelper;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
class SyndeticsPlus extends AbstractHelper
class SyndeticsPlus extends \Zend\View\Helper\AbstractHelper
{
/**
* Syndetics configuration
*
* \Zend\Config\Config
*/
protected $config;
/**
* Provides access to other class methods.
* Constructor
*
* @return SyndeticsPlus
* @param \Zend\Config\Config $config Syndetics configuration (should contain
* 'plus' boolean value (true if Syndetics Plus is enabled) and 'plus_id' string
* value (Syndetics Plus user ID). If these values are absent, SyndeticsPlus
* will be disabled.
*/
public function __invoke()
public function __construct($config)
{
$this->config = ConfigReader::getConfig();
return $this;
$this->config = $config;
}
/**
......@@ -59,8 +65,8 @@ class SyndeticsPlus extends AbstractHelper
*/
public function isActive()
{
return isset($this->config->Syndetics->plus)
? $this->config->Syndetics->plus : false;
return isset($this->config->plus)
? $this->config->plus : false;
}
/**
......@@ -70,10 +76,10 @@ class SyndeticsPlus extends AbstractHelper
*/
public function getScript()
{
// Determine whether to include script tag for syndetics plus
if (isset($this->config->Syndetics->plus_id)) {
// Determine whether to include script tag for SyndeticsPlus
if (isset($this->config->plus_id)) {
return "http://plus.syndetics.com/widget.php?id="
. urlencode($this->config->Syndetics->plus_id);
. urlencode($this->config->plus_id);
}
return null;
......
......@@ -33,6 +33,12 @@ return array(
$sm->getServiceLocator()->get('SearchManager')
);
},
'syndeticsplus' => function ($sm) {
$config = \VuFind\Config\Reader::getConfig();
return new \VuFind\View\Helper\Root\SyndeticsPlus(
isset($config->Syndetics) ? $config->Syndetics : null
);
}
),
'invokables' => array(
'addellipsis' => 'VuFind\View\Helper\Root\AddEllipsis',
......@@ -60,7 +66,6 @@ return array(
'safemoneyformat' => 'VuFind\View\Helper\Root\SafeMoneyFormat',
'sortfacetlist' => 'VuFind\View\Helper\Root\SortFacetList',
'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',
......
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