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