ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ClassificationSessionRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 public const BASE_SESSION_KEY = 'clsfct';
26 protected string $key;
27
28 protected int $base_ref_id;
29
30 public function __construct(int $base_ref_id)
31 {
32 $this->base_ref_id = $base_ref_id;
33 $this->key = self::BASE_SESSION_KEY . "_" . $base_ref_id;
34 }
35
36 public function unsetAll(): void
37 {
38 \ilSession::clear($this->key);
39 }
40
41 public function unsetValueForProvider(string $provider): void
42 {
43 if (\ilSession::has($this->key)) {
44 $vals = \ilSession::get($this->key);
45 unset($vals[$provider]);
46 \ilSession::set($this->key, $vals);
47 }
48 }
49
50 public function isEmpty(): bool
51 {
52 return !\ilSession::has($this->key);
53 }
54
55 public function getValueForProvider(string $provider): array
56 {
57 if (\ilSession::has($this->key)) {
58 $vals = \ilSession::get($this->key);
59 return $vals[$provider] ?? [];
60 }
61 return [];
62 }
63
64 public function setValueForProvider(string $provider, array $value): void
65 {
66 $vals = [];
67 if (\ilSession::has($this->key)) {
68 $vals = \ilSession::get($this->key);
69 }
70 $vals[$provider] = $value;
71 \ilSession::set($this->key, $vals);
72 }
73}
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
static has($a_var)
$provider
Definition: ltitoken.php:80