Newer
Older
<?php
/**
* Copyright (C) Leipzig University Library 2019.
*
* 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
*
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
*/
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use VuFind\ILS\Connection;
use finc\Dbis\Client\Client;
use Zend\Config\Config;
use Zend\Mvc\Controller\Plugin\Params;
use Zend\View\Renderer\RendererInterface;
class GetBoss extends \VuFind\AjaxHandler\AbstractBase
{
/**
* Top-level configuration
*
* @var Config
*/
protected $config;
/**
* ILS connection
*
* @var Connection
*/
protected $ils;
/**
* HTTP Service
*
* @var Client
*/
protected $dbisClient;
/**
* View renderer
*
* @var RendererInterface
*/
protected $renderer;
/**
* Constructor
*
* @param Client $dbisClient http client
* @param Config $config Top-level configuration
* @param Connection $ils ILS connection
* @param RendererInterface $renderer view
*/
public function __construct(
Client $dbisClient,
Config $config,
Connection $ils,
RendererInterface $renderer
) {
$this->config = $config;
$this->ils = $ils;
$this->dbisClient = $dbisClient;
$this->renderer = $renderer;
}
/**
* Handle a request.
*
* @param Params $params Parameter helper from controller
*
* @return array [response data, HTTP status code]
*/
public function handleRequest(Params $params)
{
$bibId = 'AAAAA';
// Stop now if the user does not have valid catalog credentials available:
if (is_array($this->ils)) {
$bibId = isset($patron['homeLibrary']) ?
$this->ils['homeLibrary'] : 'AAAAA';
}
$results = $this->dbisClient->getDbisList($bibId);
$view = [
'results' => $results
];
$html = $this->renderer->render('ajax/dbis.phtml', $view);
return $this->formatResponse(compact('html'));
}
}