Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
KeepAlive
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 handleRequest
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * "Keep Alive" AJAX handler
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2018.
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  AJAX
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 Wiki
28 */
29
30namespace VuFind\AjaxHandler;
31
32use Laminas\Mvc\Controller\Plugin\Params;
33use Laminas\Session\SessionManager;
34
35/**
36 * "Keep Alive" AJAX handler
37 *
38 * This is responsible for keeping the session alive whenever called
39 * (via JavaScript)
40 *
41 * @category VuFind
42 * @package  AJAX
43 * @author   Demian Katz <demian.katz@villanova.edu>
44 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
45 * @link     https://vufind.org/wiki/development Wiki
46 */
47class KeepAlive extends AbstractBase
48{
49    /**
50     * Session Manager
51     *
52     * @var SessionManager
53     */
54    protected $sessionManager;
55
56    /**
57     * Constructor
58     *
59     * @param SessionManager $sm Session manager
60     */
61    public function __construct(SessionManager $sm)
62    {
63        $this->sessionManager = $sm;
64    }
65
66    /**
67     * Handle a request.
68     *
69     * @param Params $params Parameter helper from controller
70     *
71     * @return array [response data, HTTP status code]
72     *
73     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
74     */
75    public function handleRequest(Params $params)
76    {
77        // Request ID from session to mark it active
78        $this->sessionManager->getId();
79        return $this->formatResponse(true);
80    }
81}