diff --git a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManagerFactory.php b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManagerFactory.php index a4f095c1713c5395bdf9bc1f5e8678bdb19336a7..10dc9f2a9e92835c9506dd7f6824af7bf27dd7e8 100644 --- a/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManagerFactory.php +++ b/module/VuFind/src/VuFind/ServiceManager/AbstractPluginManagerFactory.php @@ -41,6 +41,22 @@ use Zend\ServiceManager\Factory\FactoryInterface; */ class AbstractPluginManagerFactory implements FactoryInterface { + /** + * Determine the configuration key for the specified class name. + * + * @param string $requestedName Service being created + * + * @return string + */ + public function getConfigKey($requestedName) + { + // Extract namespace of plugin manager (chop off leading top-level + // namespace -- e.g. VuFind -- and trailing PluginManager class). + $regex = '/^[^\\\\]+\\\\(.*)\\\\PluginManager$/'; + preg_match($regex, $requestedName, $matches); + return strtolower(str_replace('\\', '_', $matches[1])); + } + /** * Create an object * @@ -61,11 +77,7 @@ class AbstractPluginManagerFactory implements FactoryInterface if (!empty($options)) { throw new \Exception('Unexpected options sent to factory.'); } - // Extract namespace of plugin manager (chop off leading top-level - // namespace -- e.g. VuFind -- and trailing PluginManager class). - $regex = '/^[^\\\\]+\\\\(.*)\\\\PluginManager$/'; - preg_match($regex, $requestedName, $matches); - $configKey = strtolower(str_replace('\\', '_', $matches[1])); + $configKey = $this->getConfigKey($requestedName); if (empty($configKey)) { $error = 'Problem determining config key for ' . $requestedName; throw new \Exception($error);