From 46d33288d0cbe5f157f4025e7860326d065eeef0 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 31 Aug 2012 08:36:02 -0400 Subject: [PATCH] Changed AbstractPluginManager interface to eliminate need to override constructor in child classes. --- .../ServiceManager/AbstractPluginManager.php | 15 +++++++++++---- .../VuFind/src/VuFind/Session/PluginManager.php | 13 +++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php index 3201131af92..d7abc47fcd0 100644 --- a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php +++ b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManager.php @@ -40,8 +40,6 @@ use Zend\ServiceManager\AbstractPluginManager as Base, */ abstract class AbstractPluginManager extends Base { - protected $expectedInterface; - /** * Validate the plugin * @@ -55,11 +53,20 @@ abstract class AbstractPluginManager extends Base */ public function validatePlugin($plugin) { - if (!($plugin instanceof $this->expectedInterface)) { + $expectedInterface = $this->getExpectedInterface(); + if (!($plugin instanceof $expectedInterface)) { throw new ServiceManagerRuntimeException( 'Plugin ' . get_class($plugin) . ' does not belong to ' - . $this->expectedInterface + . $expectedInterface ); } } + + /** + * Return the name of the base class or interface that plug-ins must conform + * to. + * + * @return string + */ + abstract protected function getExpectedInterface(); } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Session/PluginManager.php b/module/VuFind/src/VuFind/Session/PluginManager.php index fc71c7c13ed..3aee7b72f54 100644 --- a/module/VuFind/src/VuFind/Session/PluginManager.php +++ b/module/VuFind/src/VuFind/Session/PluginManager.php @@ -40,16 +40,13 @@ use Zend\ServiceManager\ConfigInterface; class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { /** - * Constructor + * Return the name of the base class or interface that plug-ins must conform + * to. * - * Add a default initializer to ensure the plugin is valid after instance - * creation. - * - * @param null|ConfigInterface $configuration Configuration + * @return string */ - public function __construct(ConfigInterface $configuration = null) + protected function getExpectedInterface() { - $this->expectedInterface = 'Zend\Session\SaveHandler\SaveHandlerInterface'; - parent::__construct($configuration); + return 'Zend\Session\SaveHandler\SaveHandlerInterface'; } } \ No newline at end of file -- GitLab