Skip to content
Snippets Groups Projects
Commit 971e9e2d authored by Demian Katz's avatar Demian Katz Committed by GitHub
Browse files

Eliminate VuFindPluginInitializer. (#1069)

- Implementing a setPluginManager method no longer triggers auto-injection.
parent 7a256e48
Branches
Tags
No related merge requests found
......@@ -304,6 +304,7 @@ $config = [
'choiceauth' => 'VuFind\Auth\Factory::getChoiceAuth',
'facebook' => 'VuFind\Auth\Factory::getFacebook',
'ils' => 'VuFind\Auth\Factory::getILS',
'multiauth' => 'VuFind\Auth\Factory::getMultiAuth',
'multiils' => 'VuFind\Auth\Factory::getMultiILS',
'shibboleth' => 'VuFind\Auth\Factory::getShibboleth'
],
......@@ -311,7 +312,6 @@ $config = [
'cas' => 'VuFind\Auth\CAS',
'database' => 'VuFind\Auth\Database',
'ldap' => 'VuFind\Auth\LDAP',
'multiauth' => 'VuFind\Auth\MultiAuth',
'sip2' => 'VuFind\Auth\SIP2',
],
'aliases' => [
......
......@@ -54,7 +54,9 @@ class Factory
$container = new \Zend\Session\Container(
'ChoiceAuth', $sm->getServiceLocator()->get('VuFind\SessionManager')
);
return new ChoiceAuth($container);
$auth = new ChoiceAuth($container);
$auth->setPluginManager($sm);
return $auth;
}
/**
......@@ -154,6 +156,20 @@ class Factory
return $manager;
}
/**
* Construct the MultiAuth plugin.
*
* @param ServiceManager $sm Service manager.
*
* @return MultiAuth
*/
public static function getMultiAuth(ServiceManager $sm)
{
$auth = new MultiAuth();
$auth->setPluginManager($sm);
return $auth;
}
/**
* Construct the MultiILS plugin.
*
......
......@@ -57,7 +57,7 @@ abstract class AbstractPluginManager extends Base
) {
parent::__construct($configOrContainerInstance, $v3config);
$this->addInitializer(
'VuFind\ServiceManager\VuFindPluginInitializer', false
'VuFind\ServiceManager\ZendPluginInitializer', false
);
}
......
<?php
/**
* VuFind Plugin Initializer
*
* PHP version 5
*
* Copyright (C) Villanova University 2010.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package ServiceManager
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
namespace VuFind\ServiceManager;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* VuFind Plugin Initializer
*
* @category VuFind
* @package ServiceManager
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class VuFindPluginInitializer extends ZendPluginInitializer
{
/**
* Given an instance and a Plugin Manager, initialize the instance.
*
* @param object $instance Instance to initialize
* @param ServiceLocatorInterface $manager Plugin manager
*
* @return object
*/
public function initialize($instance, ServiceLocatorInterface $manager)
{
if (method_exists($instance, 'setPluginManager')) {
$instance->setPluginManager($manager);
}
return parent::initialize($instance, $manager);
}
}
......@@ -53,7 +53,9 @@ class MultiAuthTest extends \VuFindTest\Unit\DbTestCase
if (null === $config) {
$config = $this->getAuthConfig();
}
$obj = clone $this->getAuthManager()->get('MultiAuth');
$manager = $this->getAuthManager();
$obj = clone $manager->get('MultiAuth');
$obj->setPluginManager($manager);
$obj->setConfig($config);
return $obj;
}
......
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