Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
Options
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 6
72
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getSearchAction
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getView
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEpfView
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 getAdvancedSearchAction
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setOptionsFromConfig
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3/**
4 * EPF API Options
5 *
6 * PHP version 8
7 *
8 * Copyright (C) EBSCO Industries 2013
9 * Copyright (C) The National Library of Finland 2022
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2,
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 *
24 * @category VuFind
25 * @package  EBSCO
26 * @author   Michelle Milton <mmilton@epnet.com>
27 * @author   Ere Maijala <ere.maijala@helsinki.fi>
28 * @author   Maccabee Levine <msl321@lehigh.edu>
29 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
30 * @link     https://vufind.org Main Page
31 */
32
33namespace VuFind\Search\EPF;
34
35use function count;
36
37/**
38 * EPF API Options
39 *
40 * @category VuFind
41 * @package  EBSCO
42 * @author   Michelle Milton <mmilton@epnet.com>
43 * @author   Ere Maijala <ere.maijala@helsinki.fi>
44 * @author   Maccabee Levine <msl321@lehigh.edu>
45 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
46 * @link     https://vufind.org Main Page
47 */
48class Options extends \VuFind\Search\Base\Options
49{
50    /**
51     * Default view option
52     *
53     * @var ?string
54     */
55    protected $defaultView = null;
56
57    /**
58     * Search configuration
59     *
60     * @var \Laminas\Config\Config
61     */
62    protected $searchSettings;
63
64    /**
65     * Constructor
66     *
67     * @param \VuFind\Config\PluginManager $configLoader Configuration loader
68     */
69    public function __construct(
70        \VuFind\Config\PluginManager $configLoader
71    ) {
72        $this->searchIni = $this->facetsIni = 'EPF';
73        $this->searchSettings = $configLoader->get($this->searchIni);
74
75        parent::__construct($configLoader);
76
77        $this->setOptionsFromConfig();
78    }
79
80    /**
81     * Return the route name for the search results action.
82     *
83     * @return string
84     */
85    public function getSearchAction()
86    {
87        return 'epf-search';
88    }
89
90    /**
91     * Return the view associated with this configuration
92     *
93     * @return string
94     */
95    public function getView()
96    {
97        return $this->defaultView;
98    }
99
100    /**
101     * Return the view associated with this configuration
102     *
103     * @return string
104     */
105    public function getEpfView()
106    {
107        $viewArr = explode('|', $this->defaultView);
108        return (1 < count($viewArr)) ? $viewArr[1] : $this->defaultView;
109    }
110
111    /**
112     * Return the route name of the action used for performing advanced searches.
113     * Returns false if the feature is not supported.
114     *
115     * @return string|bool
116     */
117    public function getAdvancedSearchAction()
118    {
119        return false;
120    }
121
122    /**
123     * Load options from the configuration file.
124     *
125     * @return void
126     */
127    protected function setOptionsFromConfig()
128    {
129        // View preferences
130        if (isset($this->searchSettings->General->default_view)) {
131            $this->defaultView
132                = 'list|' . $this->searchSettings->General->default_view;
133        }
134    }
135}