Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3/**
4 * Interface for persisting user data in the session.
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2024.
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  Auth
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:database_gateways Wiki
28 */
29
30namespace VuFind\Auth;
31
32use Exception;
33use VuFind\Db\Entity\UserEntityInterface;
34
35/**
36 * Interface for persisting user data in the session.
37 *
38 * @category VuFind
39 * @package  Database
40 * @author   Demian Katz <demian.katz@villanova.edu>
41 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
42 * @link     https://vufind.org/wiki/development:plugins:database_gateways Wiki
43 */
44interface UserSessionPersistenceInterface
45{
46    /**
47     * Update session container to store data representing a user (used by privacy mode).
48     *
49     * @param UserEntityInterface $user User to store in session.
50     *
51     * @return void
52     * @throws Exception
53     */
54    public function addUserDataToSession(UserEntityInterface $user): void;
55
56    /**
57     * Update session container to store user ID (used outside of privacy mode).
58     *
59     * @param int $id User ID
60     *
61     * @return void
62     */
63    public function addUserIdToSession(int $id): void;
64
65    /**
66     * Clear the user data from the session.
67     *
68     * @return void
69     */
70    public function clearUserFromSession(): void;
71
72    /**
73     * Build a user entity using data from a session container. Return null if user
74     * data cannot be found.
75     *
76     * @return ?UserEntityInterface
77     */
78    public function getUserFromSession(): ?UserEntityInterface;
79
80    /**
81     * Is there user data currently stored in the session container?
82     *
83     * @return bool
84     */
85    public function hasUserSessionData(): bool;
86}