-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathSessionData.php
More file actions
41 lines (35 loc) · 1.12 KB
/
SessionData.php
File metadata and controls
41 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_SAML\Db;
use OCA\User_SAML\Model\SessionData as SessionDataModel;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;
/**
* @method getId(): string
* @method setId(string $id): void
* @method setTokenId(int $tokenId): void
* @method getTokenId(): int
*/
class SessionData extends Entity {
public ?string $data = null;
protected ?int $tokenId = null;
public function __construct() {
$this->addType('id', Types::STRING);
// technically tokenId is BIGINT, effectively no difference in the Entity context.
// It can be set to BIGINT once dropping NC 30 support.
$this->addType('tokenId', Types::INTEGER);
$this->addType('data', Types::TEXT);
}
public function setData(SessionDataModel $input): void {
$this->data = json_encode($input);
$this->markFieldUpdated('data');
}
public function getData(): SessionDataModel {
$deserialized = json_decode((string)$this->data, true);
return SessionDataModel::fromInputArray($deserialized);
}
}