Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PluginManager
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getExpectedInterface
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Related record plugin manager
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2010.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2,
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 *
23 * @category VuFind
24 * @package  Related_Records
25 * @author   Demian Katz <demian.katz@villanova.edu>
26 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27 * @link     https://vufind.org/wiki/development:plugins:related_records_modules Wiki
28 */
29
30namespace VuFind\Related;
31
32use Laminas\ServiceManager\Factory\InvokableFactory;
33
34/**
35 * Related record plugin manager
36 *
37 * @category VuFind
38 * @package  Related_Records
39 * @author   Demian Katz <demian.katz@villanova.edu>
40 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
41 * @link     https://vufind.org/wiki/development:plugins:related_records_modules Wiki
42 */
43class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
44{
45    /**
46     * Default plugin aliases.
47     *
48     * @var array
49     */
50    protected $aliases = [
51        'channels' => Channels::class,
52        'bookplate' => Bookplate::class,
53        'editions' => Deprecated::class,
54        'similar' => Similar::class,
55        'worldcateditions' => Deprecated::class,
56        'worldcatsimilar' => WorldCatSimilar::class,
57    ];
58
59    /**
60     * Default plugin factories.
61     *
62     * @var array
63     */
64    protected $factories = [
65        Channels::class => InvokableFactory::class,
66        Bookplate::class => BookplateFactory::class,
67        Deprecated::class => InvokableFactory::class,
68        Similar::class => SimilarFactory::class,
69        WorldCatSimilar::class => SimilarFactory::class,
70    ];
71
72    /**
73     * Constructor
74     *
75     * Make sure plugins are properly initialized.
76     *
77     * @param mixed $configOrContainerInstance Configuration or container instance
78     * @param array $v3config                  If $configOrContainerInstance is a
79     * container, this value will be passed to the parent constructor.
80     */
81    public function __construct(
82        $configOrContainerInstance = null,
83        array $v3config = []
84    ) {
85        // These objects are not meant to be shared -- every time we retrieve one,
86        // we are building a brand new object.
87        $this->sharedByDefault = false;
88        $this->addAbstractFactory(PluginFactory::class);
89        parent::__construct($configOrContainerInstance, $v3config);
90    }
91
92    /**
93     * Return the name of the base class or interface that plug-ins must conform
94     * to.
95     *
96     * @return string
97     */
98    protected function getExpectedInterface()
99    {
100        return RelatedInterface::class;
101    }
102}