diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 22673a553ba1ec0ba43d0e367866093607c4f104..25a3294848b8f436cd81bf7d22a0bbebb6f75801 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -89,9 +89,10 @@ class Params implements ServiceLocatorAwareInterface /** * Constructor * - * @param \VuFind\Search\Base\Options $options Options to use + * @param \VuFind\Search\Base\Options $options Options to use + * @param \VuFind\Config\PluginManager $configLoader Config loader */ - public function __construct($options) + public function __construct($options, \VuFind\Config\PluginManager $configLoader) { $this->setOptions($options); @@ -99,16 +100,6 @@ class Params implements ServiceLocatorAwareInterface $this->query = new Query(); } - /** - * Perform initialization that cannot occur in constructor due to need for - * injected dependencies. - * - * @return void - */ - public function init() - { - } - /** * Get the search options object. * diff --git a/module/VuFind/src/VuFind/Search/Favorites/Params.php b/module/VuFind/src/VuFind/Search/Favorites/Params.php index d7548db7ab0c711b1178fa4ff850143ea8661b26..a6e6a429dca398e5017c2f7629983c18f935674e 100644 --- a/module/VuFind/src/VuFind/Search/Favorites/Params.php +++ b/module/VuFind/src/VuFind/Search/Favorites/Params.php @@ -48,12 +48,12 @@ class Params extends \VuFind\Search\Base\Params /** * Constructor * - * @param \VuFind\Search\Base\Options $options Options to use (null to load - * defaults) + * @param \VuFind\Search\Base\Options $options Options to use + * @param \VuFind\Config\PluginManager $configLoader Config loader */ - public function __construct($options = null) + public function __construct($options, \VuFind\Config\PluginManager $configLoader) { - parent::__construct($options); + parent::__construct($options, $configLoader); $this->recommendationsEnabled(true); } diff --git a/module/VuFind/src/VuFind/Search/Params/PluginFactory.php b/module/VuFind/src/VuFind/Search/Params/PluginFactory.php index 4680af41c065cb0ca98effbe1577360e0ebf0083..c7361ea19b04bfbc12e612860b63a8e3859f72f3 100644 --- a/module/VuFind/src/VuFind/Search/Params/PluginFactory.php +++ b/module/VuFind/src/VuFind/Search/Params/PluginFactory.php @@ -64,10 +64,9 @@ class PluginFactory extends \VuFind\ServiceManager\AbstractPluginFactory ->get('VuFind\SearchOptionsPluginManager')->get($requestedName); $class = $this->getClassName($name, $requestedName); // Clone the options instance in case caller modifies it: - $obj = new $class(clone($options)); - // TODO: eliminate init method to get rid of this awkwardness: - $obj->setServiceLocator($serviceLocator->getServiceLocator()); - $obj->init(); - return $obj; + return new $class( + clone($options), + $serviceLocator->getServiceLocator()->get('VuFind\Config') + ); } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php index bc939d534ac172a299fccbae24b39d819ed61f88..e1935653e84ab265c2f401608e01cb9d87a81865 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Params.php +++ b/module/VuFind/src/VuFind/Search/Solr/Params.php @@ -67,17 +67,17 @@ class Params extends \VuFind\Search\Base\Params protected $facetSort = null; /** - * Perform initialization that cannot occur in constructor due to need for - * injected dependencies. + * Constructor * - * @return void + * @param \VuFind\Search\Base\Options $options Options to use + * @param \VuFind\Config\PluginManager $configLoader Config loader */ - public function init() + public function __construct($options, \VuFind\Config\PluginManager $configLoader) { - parent::init(); + parent::__construct($options, $configLoader); // Use basic facet limit by default, if set: - $config = $this->getServiceLocator()->get('VuFind\Config')->get('facets'); + $config = $configLoader->get('facets'); if (isset($config->Results_Settings->facet_limit) && is_numeric($config->Results_Settings->facet_limit) ) {