ILIAS  release_8 Revision v8.24
class.ilForumThreadSettingsSessionStorage.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private string $key;
24
25 public function __construct(string $session_key)
26 {
27 $this->key = $session_key;
28 }
29
33 private function getSessionCollection(): array
34 {
35 $frm_sess = ilSession::get('frm_sess');
36 if (!is_array($frm_sess)) {
37 $frm_sess = [];
38 }
39
40 if (!isset($frm_sess[$this->key]) || !is_array($frm_sess[$this->key])) {
41 $frm_sess[$this->key] = [];
42 }
43
44 return $frm_sess;
45 }
46
52 public function get(int $thread_id, $default = null)
53 {
54 $frm_sess = $this->getSessionCollection();
55
56 return $frm_sess[$this->key][$thread_id] ?? $default;
57 }
58
63 public function set(int $thread_id, $value): void
64 {
65 $frm_sess = $this->getSessionCollection();
66
67 $frm_sess[$this->key][$thread_id] = $value;
68
69 ilSession::set('frm_sess', $frm_sess);
70 }
71}
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.