Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChannelsController
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 4
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 homeAction
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 recordAction
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 searchAction
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * Channels Controller
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2016.
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  Controller
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/indexing:alphabetical_heading_browse Wiki
28 */
29
30namespace VuFind\Controller;
31
32use Laminas\ServiceManager\ServiceLocatorInterface;
33use VuFind\ChannelProvider\ChannelLoader;
34
35/**
36 * Channels Class
37 *
38 * Controls the alphabetical browsing feature
39 *
40 * @category VuFind
41 * @package  Controller
42 * @author   Demian Katz <demian.katz@villanova.edu>
43 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
44 * @link     https://vufind.org/wiki/indexing:alphabetical_heading_browse Wiki
45 */
46class ChannelsController extends AbstractBase
47{
48    /**
49     * Channel loader
50     *
51     * @var ChannelLoader
52     */
53    protected $loader;
54
55    /**
56     * Constructor
57     *
58     * @param ChannelLoader           $loader Channel loader
59     * @param ServiceLocatorInterface $sm     Top-level service manager (needed for
60     * some AbstractBase behavior)
61     */
62    public function __construct(ChannelLoader $loader, ServiceLocatorInterface $sm)
63    {
64        $this->loader = $loader;
65        parent::__construct($sm);
66    }
67
68    /**
69     * Generates static front page of channels.
70     *
71     * @return \Laminas\View\Model\ViewModel
72     */
73    public function homeAction()
74    {
75        $source = $this->params()->fromQuery('source', DEFAULT_SEARCH_BACKEND);
76        $activeChannel = $this->params()->fromQuery('channelProvider');
77        $token = $this->params()->fromQuery('channelToken');
78        $context = $this->loader->getHomeContext($token, $activeChannel, $source);
79        return $this->createViewModel($context);
80    }
81
82    /**
83     * Generates channels for a record.
84     *
85     * @return \Laminas\View\Model\ViewModel
86     */
87    public function recordAction()
88    {
89        $recordId = $this->params()->fromQuery('id');
90        $source = $this->params()->fromQuery('source', DEFAULT_SEARCH_BACKEND);
91        $activeChannel = $this->params()->fromQuery('channelProvider');
92        $token = $this->params()->fromQuery('channelToken');
93        $context = $this->loader
94            ->getRecordContext($recordId, $token, $activeChannel, $source);
95        return $this->createViewModel($context);
96    }
97
98    /**
99     * Generates channels for a search.
100     *
101     * @return \Laminas\View\Model\ViewModel
102     */
103    public function searchAction()
104    {
105        // Send both GET and POST variables to search class:
106        $request = $this->getRequest()->getQuery()->toArray()
107            + $this->getRequest()->getPost()->toArray();
108        $source = $this->params()->fromQuery('source', DEFAULT_SEARCH_BACKEND);
109        $activeChannel = $this->params()->fromQuery('channelProvider');
110        $token = $this->params()->fromQuery('channelToken');
111        $context = $this->loader
112            ->getSearchContext($request, $token, $activeChannel, $source);
113        return $this->createViewModel($context);
114    }
115}