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

Adjusted plugin managers to have explicitly-injected service locators.

- Improves forward-compatibility with ZF3.
parent eaec2515
No related merge requests found
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki * @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
*/ */
namespace VuFind\Recommend; namespace VuFind\Recommend;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Recommendation module plugin manager * Recommendation module plugin manager
...@@ -42,16 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -42,16 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param ConfigInterface $configuration Configuration settings (optional) * Make sure plugins are properly initialized.
*
* @param mixed $configOrContainerInstance Configuration or container instance
* @param array $v3config If $configOrContainerInstance is a
* container, this value will be passed to the parent constructor.
*/ */
public function __construct(ConfigInterface $configuration = null) public function __construct($configOrContainerInstance = null,
{ array $v3config = []
// These plugins are not meant to be shared -- the same module may be used ) {
// multiple times with different configurations, so we need to build a new // These objects are not meant to be shared -- every time we retrieve one,
// copy each time the plugin is retrieved. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
parent::__construct($configuration); parent::__construct($configOrContainerInstance, $v3config);
} }
/** /**
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki * @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/ */
namespace VuFind\RecordDriver; namespace VuFind\RecordDriver;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Record driver plugin manager * Record driver plugin manager
...@@ -42,15 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -42,15 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param ConfigInterface $configuration Configuration settings (optional) * Make sure plugins are properly initialized.
*
* @param mixed $configOrContainerInstance Configuration or container instance
* @param array $v3config If $configOrContainerInstance is a
* container, this value will be passed to the parent constructor.
*/ */
public function __construct(ConfigInterface $configuration = null) public function __construct($configOrContainerInstance = null,
{ array $v3config = []
// Record drivers are not meant to be shared -- every time we retrieve one, ) {
// These objects are not meant to be shared -- every time we retrieve one,
// we are building a brand new object. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
parent::__construct($configuration); parent::__construct($configOrContainerInstance, $v3config);
// Add an initializer for setting up hierarchies // Add an initializer for setting up hierarchies
$initializer = function ($instance, $manager) { $initializer = function ($instance, $manager) {
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* @link https://vufind.org/wiki/development:plugins:related_records_modules Wiki * @link https://vufind.org/wiki/development:plugins:related_records_modules Wiki
*/ */
namespace VuFind\Related; namespace VuFind\Related;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Related record plugin manager * Related record plugin manager
...@@ -42,16 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -42,16 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param ConfigInterface $configuration Configuration settings (optional) * Make sure plugins are properly initialized.
*
* @param mixed $configOrContainerInstance Configuration or container instance
* @param array $v3config If $configOrContainerInstance is a
* container, this value will be passed to the parent constructor.
*/ */
public function __construct(ConfigInterface $configuration = null) public function __construct($configOrContainerInstance = null,
{ array $v3config = []
// These plugins are not meant to be shared -- the same module may be used ) {
// multiple times with different configurations, so we need to build a new // These objects are not meant to be shared -- every time we retrieve one,
// copy each time the plugin is retrieved. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
parent::__construct($configuration); parent::__construct($configOrContainerInstance, $v3config);
} }
/** /**
......
...@@ -70,9 +70,9 @@ class DynamicRoleProviderFactory implements FactoryInterface ...@@ -70,9 +70,9 @@ class DynamicRoleProviderFactory implements FactoryInterface
ServiceLocatorInterface $serviceLocator, array $rbacConfig ServiceLocatorInterface $serviceLocator, array $rbacConfig
) { ) {
$pm = new PermissionProvider\PluginManager( $pm = new PermissionProvider\PluginManager(
new Config($rbacConfig['vufind_permission_provider_manager']) $serviceLocator->getServiceLocator(),
$rbacConfig['vufind_permission_provider_manager']
); );
$pm->setServiceLocator($serviceLocator->getServiceLocator());
return $pm; return $pm;
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki * @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/ */
namespace VuFind\Search\Params; namespace VuFind\Search\Params;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Search params plugin manager * Search params plugin manager
...@@ -42,15 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -42,15 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param ConfigInterface $configuration Configuration settings (optional) * Make sure plugins are properly initialized.
*
* @param mixed $configOrContainerInstance Configuration or container instance
* @param array $v3config If $configOrContainerInstance is a
* container, this value will be passed to the parent constructor.
*/ */
public function __construct(ConfigInterface $configuration = null) public function __construct($configOrContainerInstance = null,
{ array $v3config = []
) {
// These objects are not meant to be shared -- every time we retrieve one, // These objects are not meant to be shared -- every time we retrieve one,
// we are building a brand new object. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
parent::__construct($configuration); parent::__construct($configOrContainerInstance, $v3config);
} }
/** /**
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki * @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/ */
namespace VuFind\Search\Results; namespace VuFind\Search\Results;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Search results plugin manager * Search results plugin manager
...@@ -42,15 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -42,15 +41,20 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param ConfigInterface $configuration Configuration settings (optional) * Make sure plugins are properly initialized.
*
* @param mixed $configOrContainerInstance Configuration or container instance
* @param array $v3config If $configOrContainerInstance is a
* container, this value will be passed to the parent constructor.
*/ */
public function __construct(ConfigInterface $configuration = null) public function __construct($configOrContainerInstance = null,
{ array $v3config = []
) {
// These objects are not meant to be shared -- every time we retrieve one, // These objects are not meant to be shared -- every time we retrieve one,
// we are building a brand new object. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
parent::__construct($configuration); parent::__construct($configOrContainerInstance, $v3config);
} }
/** /**
......
...@@ -318,9 +318,7 @@ class Factory ...@@ -318,9 +318,7 @@ class Factory
$configKey = strtolower(str_replace('\\', '_', $ns)); $configKey = strtolower(str_replace('\\', '_', $ns));
$config = $sm->get('Config'); $config = $sm->get('Config');
return new $className( return new $className(
new \Zend\ServiceManager\Config( $sm, $config['vufind']['plugin_managers'][$configKey]
$config['vufind']['plugin_managers'][$configKey]
)
); );
} }
......
...@@ -46,13 +46,16 @@ abstract class AbstractPluginManager extends Base ...@@ -46,13 +46,16 @@ abstract class AbstractPluginManager extends Base
/** /**
* Constructor * Constructor
* *
* Make sure table gateways are properly initialized. * Make sure plugins are properly initialized.
* *
* @param ConfigInterface $configuration Configuration settings (optional) * @param mixed $configOrContainerInstance Configuration or container instance
* @param array $v3config If $configOrContainerInstance is a
* container, this value will be passed to the parent constructor.
*/ */
public function __construct(ConfigInterface $configuration = null) public function __construct($configOrContainerInstance = null,
{ array $v3config = []
parent::__construct($configuration); ) {
parent::__construct($configOrContainerInstance, $v3config);
$this->addInitializer( $this->addInitializer(
['VuFind\ServiceManager\Initializer', 'initPlugin'], false ['VuFind\ServiceManager\Initializer', 'initPlugin'], false
); );
......
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