From b4a1ccd18d54f0d1bdf4f284a435c6ae3cfaed3b Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 17 Jan 2018 08:43:27 -0500
Subject: [PATCH] Modernize ILS driver services. - Use fully qualified class
 names as service names. - Eliminate static factory methods. - Move
 configuration to plugin manager.

---
 module/VuFind/config/module.config.php        |  34 +-
 .../src/VuFind/ILS/Driver/AlephFactory.php    |  67 ++++
 .../src/VuFind/ILS/Driver/DemoFactory.php     |  72 +++++
 .../Driver/DriverWithDateConverterFactory.php |  76 +++++
 .../VuFind/src/VuFind/ILS/Driver/Factory.php  | 298 ------------------
 .../VuFind/ILS/Driver/MultiBackendFactory.php |  70 ++++
 .../src/VuFind/ILS/Driver/NoILSFactory.php    |  66 ++++
 .../src/VuFind/ILS/Driver/PAIAFactory.php     |  68 ++++
 .../src/VuFind/ILS/Driver/PluginManager.php   |  99 ++++++
 .../VuFind/ILS/Driver/SierraRestFactory.php   |  69 ++++
 .../src/VuFind/ILS/Driver/SymphonyFactory.php |  69 ++++
 .../ILS/Driver/VoyagerRestfulFactory.php      |  67 ++++
 12 files changed, 724 insertions(+), 331 deletions(-)
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/AlephFactory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/DemoFactory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/DriverWithDateConverterFactory.php
 delete mode 100644 module/VuFind/src/VuFind/ILS/Driver/Factory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/MultiBackendFactory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/PAIAFactory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/SierraRestFactory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php
 create mode 100644 module/VuFind/src/VuFind/ILS/Driver/VoyagerRestfulFactory.php

diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php
index 246e123e84c..7ec8780a06c 100644
--- a/module/VuFind/config/module.config.php
+++ b/module/VuFind/config/module.config.php
@@ -441,39 +441,7 @@ $config = [
                     'jstree' => 'VuFind\Hierarchy\TreeRenderer\Factory::getJSTree'
                 ],
             ],
-            'ils_driver' => [
-                'abstract_factories' => ['VuFind\ILS\Driver\PluginFactory'],
-                'factories' => [
-                    'aleph' => 'VuFind\ILS\Driver\Factory::getAleph',
-                    'daia' => 'VuFind\ILS\Driver\Factory::getDAIA',
-                    'demo' => 'VuFind\ILS\Driver\Factory::getDemo',
-                    'horizon' => 'VuFind\ILS\Driver\Factory::getHorizon',
-                    'horizonxmlapi' => 'VuFind\ILS\Driver\Factory::getHorizonXMLAPI',
-                    'lbs4' => 'VuFind\ILS\Driver\Factory::getLBS4',
-                    'multibackend' => 'VuFind\ILS\Driver\Factory::getMultiBackend',
-                    'noils' => 'VuFind\ILS\Driver\Factory::getNoILS',
-                    'paia' => 'VuFind\ILS\Driver\Factory::getPAIA',
-                    'koha' => 'VuFind\ILS\Driver\Factory::getKoha',
-                    'kohailsdi' => 'VuFind\ILS\Driver\Factory::getKohaILSDI',
-                    'sierrarest' => 'VuFind\ILS\Driver\Factory::getSierraRest',
-                    'symphony' => 'VuFind\ILS\Driver\Factory::getSymphony',
-                    'unicorn' => 'VuFind\ILS\Driver\Factory::getUnicorn',
-                    'voyager' => 'VuFind\ILS\Driver\Factory::getVoyager',
-                    'voyagerrestful' => 'VuFind\ILS\Driver\Factory::getVoyagerRestful',
-                ],
-                'invokables' => [
-                    'amicus' => 'VuFind\ILS\Driver\Amicus',
-                    'claviussql' => 'VuFind\ILS\Driver\ClaviusSQL',
-                    'evergreen' => 'VuFind\ILS\Driver\Evergreen',
-                    'innovative' => 'VuFind\ILS\Driver\Innovative',
-                    'newgenlib' => 'VuFind\ILS\Driver\NewGenLib',
-                    'polaris' => 'VuFind\ILS\Driver\Polaris',
-                    'sample' => 'VuFind\ILS\Driver\Sample',
-                    'sierra' => 'VuFind\ILS\Driver\Sierra',
-                    'virtua' => 'VuFind\ILS\Driver\Virtua',
-                    'xcncip2' => 'VuFind\ILS\Driver\XCNCIP2',
-                ],
-            ],
+            'ils_driver' => [ /* See VuFind\ILS\Driver\PluginManager for defaults */ ],
             'recommend' => [ /* See VuFind\Recommend\PluginManager for defaults */ ],
             'recorddriver' => [ /* See VuFind\RecordDriver\PluginManager for defaults */ ],
             'recordtab' => [
diff --git a/module/VuFind/src/VuFind/ILS/Driver/AlephFactory.php b/module/VuFind/src/VuFind/ILS/Driver/AlephFactory.php
new file mode 100644
index 00000000000..d15bce9329d
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/AlephFactory.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Factory for Aleph ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+
+/**
+ * Factory for Aleph ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 AlephFactory extends DriverWithDateConverterFactory
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        return parent::__invoke(
+            $container, $requestedName, [$container->get('VuFind\CacheManager')]
+        );
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/DemoFactory.php b/module/VuFind/src/VuFind/ILS/Driver/DemoFactory.php
new file mode 100644
index 00000000000..a123c8772bf
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/DemoFactory.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Factory for Demo ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+
+/**
+ * Factory for Demo ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 DemoFactory extends DriverWithDateConverterFactory
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        $sessionFactory = function () use ($container) {
+            $manager = $container->get('VuFind\SessionManager');
+            return new \Zend\Session\Container('DemoDriver', $manager);
+        };
+        return parent::__invoke(
+            $container, $requestedName,
+            [$container->get('VuFind\Search'), $sessionFactory]
+        );
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/DriverWithDateConverterFactory.php b/module/VuFind/src/VuFind/ILS/Driver/DriverWithDateConverterFactory.php
new file mode 100644
index 00000000000..af63d8f7e79
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/DriverWithDateConverterFactory.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Generic factory suitable for most ILS drivers.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+use Zend\ServiceManager\Factory\FactoryInterface;
+
+/**
+ * Generic factory suitable for most ILS drivers.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 DriverWithDateConverterFactory implements FactoryInterface
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        // Set up the driver with the date converter (and any extra parameters
+        // passed in as options):
+        $driver = new $requestedName(
+            $container->get('VuFind\DateConverter'), ...($options ?: [])
+        );
+
+        // Populate cache storage if a setCacheStorage method is present:
+        if (method_exists($driver, 'setCacheStorage')) {
+            $driver->setCacheStorage(
+                $container->get('VuFind\CacheManager')->getCache('object')
+            );
+        }
+
+        return $driver;
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/Factory.php b/module/VuFind/src/VuFind/ILS/Driver/Factory.php
deleted file mode 100644
index c686b5f2aa2..00000000000
--- a/module/VuFind/src/VuFind/ILS/Driver/Factory.php
+++ /dev/null
@@ -1,298 +0,0 @@
-<?php
-/**
- * ILS Driver Factory Class
- *
- * PHP version 5
- *
- * Copyright (C) Villanova University 2014.
- *
- * 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  ILS_Drivers
- * @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:plugins:hierarchy_components Wiki
- */
-namespace VuFind\ILS\Driver;
-
-use Zend\ServiceManager\ServiceManager;
-
-/**
- * ILS Driver Factory Class
- *
- * @category VuFind
- * @package  ILS_Drivers
- * @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:plugins:hierarchy_components Wiki
- *
- * @codeCoverageIgnore
- */
-class Factory
-{
-    /**
-     * Factory for Aleph driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return Aleph
-     */
-    public static function getAleph(ServiceManager $sm)
-    {
-        return new Aleph(
-            $sm->get('VuFind\DateConverter'),
-            $sm->get('VuFind\CacheManager')
-        );
-    }
-
-    /**
-     * Factory for DAIA driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return DAIA
-     */
-    public static function getDAIA(ServiceManager $sm)
-    {
-        $daia = new DAIA(
-            $sm->get('VuFind\DateConverter')
-        );
-
-        $daia->setCacheStorage(
-            $sm->get('VuFind\CacheManager')->getCache('object')
-        );
-
-        return $daia;
-    }
-
-    /**
-     * Factory for LBS4 driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return LBS4
-     */
-    public static function getLBS4(ServiceManager $sm)
-    {
-        return new LBS4(
-            $sm->get('VuFind\DateConverter')
-        );
-    }
-
-    /**
-     * Factory for Demo driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return Demo
-     */
-    public static function getDemo(ServiceManager $sm)
-    {
-        $sessionFactory = function () use ($sm) {
-            $manager = $sm->get('VuFind\SessionManager');
-            return new \Zend\Session\Container('DemoDriver', $manager);
-        };
-        return new Demo(
-            $sm->get('VuFind\DateConverter'),
-            $sm->get('VuFind\Search'), $sessionFactory
-        );
-    }
-
-    /**
-     * Factory for Horizon driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return Horizon
-     */
-    public static function getHorizon(ServiceManager $sm)
-    {
-        return new Horizon($sm->get('VuFind\DateConverter'));
-    }
-
-    /**
-     * Factory for HorizonXMLAPI driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return HorizonXMLAPI
-     */
-    public static function getHorizonXMLAPI(ServiceManager $sm)
-    {
-        return new HorizonXMLAPI(
-            $sm->get('VuFind\DateConverter')
-        );
-    }
-
-    /**
-     * Factory for MultiBackend driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return MultiBackend
-     */
-    public static function getMultiBackend(ServiceManager $sm)
-    {
-        return new MultiBackend(
-            $sm->get('VuFind\Config'),
-            $sm->get('VuFind\ILSAuthenticator'),
-            $sm
-        );
-    }
-
-    /**
-     * Factory for NoILS driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return NoILS
-     */
-    public static function getNoILS(ServiceManager $sm)
-    {
-        return new NoILS($sm->get('VuFind\RecordLoader'));
-    }
-
-    /**
-     * Factory for PAIA driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return PAIA
-     */
-    public static function getPAIA(ServiceManager $sm)
-    {
-        $paia = new PAIA(
-            $sm->get('VuFind\DateConverter'),
-            $sm->get('VuFind\SessionManager')
-        );
-
-        $paia->setCacheStorage(
-            $sm->get('VuFind\CacheManager')->getCache('object')
-        );
-
-        return $paia;
-    }
-
-    /**
-     * Factory for Koha driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return Koha
-     */
-    public static function getKoha(ServiceManager $sm)
-    {
-        return new Koha($sm->get('VuFind\DateConverter'));
-    }
-
-    /**
-     * Factory for KohaILSDI driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return KohaILSDI
-     */
-    public static function getKohaILSDI(ServiceManager $sm)
-    {
-        $koha = new KohaILSDI($sm->get('VuFind\DateConverter'));
-        $koha->setCacheStorage(
-            $sm->get('VuFind\CacheManager')->getCache('object')
-        );
-        return $koha;
-    }
-
-    /**
-     * Factory for Sierra REST driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return SierraRest
-     */
-    public static function getSierraRest(ServiceManager $sm)
-    {
-        $sessionFactory = function ($namespace) use ($sm) {
-            $manager = $sm->get('VuFind\SessionManager');
-            return new \Zend\Session\Container("SierraRest_$namespace", $manager);
-        };
-
-        $driver = new SierraRest(
-            $sm->get('VuFind\DateConverter'),
-            $sessionFactory
-        );
-        $driver->setCacheStorage(
-            $sm->get('VuFind\CacheManager')->getCache('object')
-        );
-        return $driver;
-    }
-
-    /**
-     * Factory for Symphony driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return Symphony
-     */
-    public static function getSymphony(ServiceManager $sm)
-    {
-        return new Symphony(
-            $sm->get('VuFind\RecordLoader'),
-            $sm->get('VuFind\CacheManager')
-        );
-    }
-
-    /**
-     * Factory for Unicorn driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return Unicorn
-     */
-    public static function getUnicorn(ServiceManager $sm)
-    {
-        return new Unicorn($sm->get('VuFind\DateConverter'));
-    }
-
-    /**
-     * Factory for Voyager driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return Voyager
-     */
-    public static function getVoyager(ServiceManager $sm)
-    {
-        return new Voyager($sm->get('VuFind\DateConverter'));
-    }
-
-    /**
-     * Factory for VoyagerRestful driver.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return VoyagerRestful
-     */
-    public static function getVoyagerRestful(ServiceManager $sm)
-    {
-        $ils = $sm->get('VuFind\ILSHoldSettings');
-        $vr = new VoyagerRestful(
-            $sm->get('VuFind\DateConverter'),
-            $ils->getHoldsMode(), $ils->getTitleHoldsMode()
-        );
-        $vr->setCacheStorage(
-            $sm->get('VuFind\CacheManager')->getCache('object')
-        );
-        return $vr;
-    }
-}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/MultiBackendFactory.php b/module/VuFind/src/VuFind/ILS/Driver/MultiBackendFactory.php
new file mode 100644
index 00000000000..18210a13e4a
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/MultiBackendFactory.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Factory for MultiBackend ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+use Zend\ServiceManager\Factory\FactoryInterface;
+
+/**
+ * Factory for MultiBackend ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 MultiBackendFactory implements FactoryInterface
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        return new $requestedName(
+            $container->get('VuFind\Config'),
+            $container->get('VuFind\ILSAuthenticator'),
+            $container->get('VuFind\ILSDriverPluginManager')
+        );
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php b/module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php
new file mode 100644
index 00000000000..278d90720cf
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/NoILSFactory.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Factory for NoILS ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+use Zend\ServiceManager\Factory\FactoryInterface;
+
+/**
+ * Factory for NoILS ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 NoILSFactory implements FactoryInterface
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        return new $requestedName($container->get('VuFind\RecordLoader'));
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/PAIAFactory.php b/module/VuFind/src/VuFind/ILS/Driver/PAIAFactory.php
new file mode 100644
index 00000000000..7d21ff4ebec
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/PAIAFactory.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Factory for PAIA ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+
+/**
+ * Factory for PAIA ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 PAIAFactory extends DriverWithDateConverterFactory
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        return parent::__invoke(
+            $container, $requestedName,
+            [$container->get('VuFind\SessionManager')]
+        );
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/PluginManager.php b/module/VuFind/src/VuFind/ILS/Driver/PluginManager.php
index 60f16b4b9b9..48372e583d0 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/PluginManager.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/PluginManager.php
@@ -38,6 +38,105 @@ namespace VuFind\ILS\Driver;
  */
 class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
 {
+    /**
+     * Default plugin aliases.
+     *
+     * @var array
+     */
+    protected $aliases = [
+        'aleph' => 'VuFind\ILS\Driver\Aleph',
+        'amicus' => 'VuFind\ILS\Driver\Amicus',
+        'claviussql' => 'VuFind\ILS\Driver\ClaviusSQL',
+        'daia' => 'VuFind\ILS\Driver\DAIA',
+        'demo' => 'VuFind\ILS\Driver\Demo',
+        'evergreen' => 'VuFind\ILS\Driver\Evergreen',
+        'horizon' => 'VuFind\ILS\Driver\Horizon',
+        'horizonxmlapi' => 'VuFind\ILS\Driver\HorizonXMLAPI',
+        'innovative' => 'VuFind\ILS\Driver\Innovative',
+        'koha' => 'VuFind\ILS\Driver\Koha',
+        'kohailsdi' => 'VuFind\ILS\Driver\KohaILSDI',
+        'lbs4' => 'VuFind\ILS\Driver\LBS4',
+        'multibackend' => 'VuFind\ILS\Driver\MultiBackend',
+        'newgenlib' => 'VuFind\ILS\Driver\NewGenLib',
+        'noils' => 'VuFind\ILS\Driver\NoILS',
+        'paia' => 'VuFind\ILS\Driver\PAIA',
+        'polaris' => 'VuFind\ILS\Driver\Polaris',
+        'sample' => 'VuFind\ILS\Driver\Sample',
+        'sierra' => 'VuFind\ILS\Driver\Sierra',
+        'sierrarest' => 'VuFind\ILS\Driver\SierraRest',
+        'symphony' => 'VuFind\ILS\Driver\Symphony',
+        'unicorn' => 'VuFind\ILS\Driver\Unicorn',
+        'virtua' => 'VuFind\ILS\Driver\Virtua',
+        'voyager' => 'VuFind\ILS\Driver\Voyager',
+        'voyagerrestful' => 'VuFind\ILS\Driver\VoyagerRestful',
+        'xcncip2' => 'VuFind\ILS\Driver\XCNCIP2',
+    ];
+
+    /**
+     * Default plugin factories.
+     *
+     * @var array
+     */
+    protected $factories = [
+        'VuFind\ILS\Driver\Aleph' => 'VuFind\ILS\Driver\AlephFactory',
+        'VuFind\ILS\Driver\Amicus' => 'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\ClaviusSQL' =>
+            'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\DAIA' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\Demo' => 'VuFind\ILS\Driver\DemoFactory',
+        'VuFind\ILS\Driver\Evergreen' =>
+            'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\Horizon' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\HorizonXMLAPI' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\Innovative' =>
+            'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\Koha' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\KohaILSDI' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\LBS4' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\MultiBackend' => 'VuFind\ILS\Driver\MultiBackendFactory',
+        'VuFind\ILS\Driver\NewGenLib' =>
+            'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\NoILS' => 'VuFind\ILS\Driver\NoILSFactory',
+        'VuFind\ILS\Driver\PAIA' => 'VuFind\ILS\Driver\PAIAFactory',
+        'VuFind\ILS\Driver\Polaris' =>
+            'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\Sample' => 'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\Sierra' => 'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\SierraRest' => 'VuFind\ILS\Driver\SierraRestFactory',
+        'VuFind\ILS\Driver\Symphony' => 'VuFind\ILS\Driver\SymphonyFactory',
+        'VuFind\ILS\Driver\Unicorn' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\Virtua' => 'Zend\ServiceManager\Factory\InvokableFactory',
+        'VuFind\ILS\Driver\Voyager' =>
+            'VuFind\ILS\Driver\DriverWithDateConverterFactory',
+        'VuFind\ILS\Driver\VoyagerRestful' =>
+            'VuFind\ILS\Driver\VoyagerRestfulFactory',
+        'VuFind\ILS\Driver\XCNCIP2' =>
+            'Zend\ServiceManager\Factory\InvokableFactory',
+    ];
+
+    /**
+     * Constructor
+     *
+     * 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($configOrContainerInstance = null,
+        array $v3config = []
+    ) {
+        $this->addAbstractFactory('VuFind\ILS\Driver\PluginFactory');
+        parent::__construct($configOrContainerInstance, $v3config);
+    }
+
     /**
      * Return the name of the base class or interface that plug-ins must conform
      * to.
diff --git a/module/VuFind/src/VuFind/ILS/Driver/SierraRestFactory.php b/module/VuFind/src/VuFind/ILS/Driver/SierraRestFactory.php
new file mode 100644
index 00000000000..5f9d74627ab
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/SierraRestFactory.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Factory for SierraRest ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+
+/**
+ * Factory for SierraRest ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 SierraRestFactory extends DriverWithDateConverterFactory
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        $sessionFactory = function ($namespace) use ($container) {
+            $manager = $container->get('VuFind\SessionManager');
+            return new \Zend\Session\Container("SierraRest_$namespace", $manager);
+        };
+        return parent::__invoke($container, $requestedName, [$sessionFactory]);
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php b/module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php
new file mode 100644
index 00000000000..548e80ad8f0
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/SymphonyFactory.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Factory for Symphony ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+use Zend\ServiceManager\Factory\FactoryInterface;
+
+/**
+ * Factory for Symphony ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 SymphonyFactory implements FactoryInterface
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        return new $requestedName(
+            $container->get('VuFind\RecordLoader'),
+            $container->get('VuFind\CacheManager')
+        );
+    }
+}
diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestfulFactory.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestfulFactory.php
new file mode 100644
index 00000000000..4e5cea14886
--- /dev/null
+++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestfulFactory.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Factory for VoyagerRestful ILS driver.
+ *
+ * PHP version 5
+ *
+ * Copyright (C) Villanova University 2018.
+ *
+ * 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  ILS_Drivers
+ * @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\ILS\Driver;
+
+use Interop\Container\ContainerInterface;
+
+/**
+ * Factory for VoyagerRestful ILS driver.
+ *
+ * @category VuFind
+ * @package  ILS_Drivers
+ * @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 VoyagerRestfulFactory extends DriverWithDateConverterFactory
+{
+    /**
+     * Create an object
+     *
+     * @param ContainerInterface $container     Service manager
+     * @param string             $requestedName Service being created
+     * @param null|array         $options       Extra options (optional)
+     *
+     * @return object
+     *
+     * @throws ServiceNotFoundException if unable to resolve the service.
+     * @throws ServiceNotCreatedException if an exception is raised when
+     * creating a service.
+     * @throws ContainerException if any other error occurs
+     */
+    public function __invoke(ContainerInterface $container, $requestedName,
+        array $options = null
+    ) {
+        if (!empty($options)) {
+            throw new \Exception('Unexpected options passed to factory.');
+        }
+        $ils = $container->get('VuFind\ILSHoldSettings');
+        $extraParams = [$ils->getHoldsMode(), $ils->getTitleHoldsMode()];
+        return parent::__invoke($container, $requestedName, $extraParams);
+    }
+}
-- 
GitLab