ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilForumThreadSettingsSessionStorage.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public function __construct(private readonly string $key)
24 {
25 }
26
30 private function getSessionCollection(): array
31 {
32 $frm_sess = ilSession::get('frm_sess');
33 if (!is_array($frm_sess)) {
34 $frm_sess = [];
35 }
36
37 if (!isset($frm_sess[$this->key]) || !is_array($frm_sess[$this->key])) {
38 $frm_sess[$this->key] = [];
39 }
40
41 return $frm_sess;
42 }
43
48 public function get(int $thread_id, $default = null)
49 {
50 $frm_sess = $this->getSessionCollection();
51
52 return $frm_sess[$this->key][$thread_id] ?? $default;
53 }
54
58 public function set(int $thread_id, $value): void
59 {
60 $frm_sess = $this->getSessionCollection();
61
62 $frm_sess[$this->key][$thread_id] = $value;
63
64 ilSession::set('frm_sess', $frm_sess);
65 }
66}
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.