ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\KeyValueStorage\Internal\StorageServices Class Reference
+ Inheritance diagram for ILIAS\KeyValueStorage\Internal\StorageServices:
+ Collaboration diagram for ILIAS\KeyValueStorage\Internal\StorageServices:

Public Member Functions

 __construct (private readonly SessionRepository $session, private readonly Repository $persistent, private readonly SubjectRepository $subjects, private readonly SubjectProviders $providers, Refinery $refinery)
 
 session (array $namespace)
 Storage bound to the current user session. More...
 
 persistent (array $namespace)
 Storage that survives session boundaries until changed or cleared. More...
 
 persistentFor (SubjectResolver $subjects, array $namespace)
 Persistent storage for the subject the resolver names. More...
 
 purgeSubject (SubjectId $subject)
 Removes every subject-scoped entry for this subject, in every namespace. More...
 
 session (array $namespace)
 Storage bound to the current user session. More...
 
 persistent (array $namespace)
 Storage that survives session boundaries until changed or cleared. More...
 
 persistentFor (SubjectResolver $subjects, array $namespace)
 Persistent storage for the subject the resolver names. More...
 
 purgeSubject (SubjectId $subject)
 Removes every subject-scoped entry for this subject, in every namespace. More...
 

Private Member Functions

 subjectScope (SubjectId $subject)
 
 store (string $scope, StorageNamespace $namespace, Repository $repository)
 

Private Attributes

readonly KeyRules $key_rules
 
readonly Values $values
 
array $stores = []
 

Detailed Description

Definition at line 35 of file StorageServices.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\KeyValueStorage\Internal\StorageServices::__construct ( private readonly SessionRepository  $session,
private readonly Repository  $persistent,
private readonly SubjectRepository  $subjects,
private readonly SubjectProviders  $providers,
Refinery  $refinery 
)

Definition at line 44 of file StorageServices.php.

50 {
51 $this->key_rules = new KeyRules();
52 $this->values = new Values($refinery);
53 }
The rules every storage key has to follow.
Definition: KeyRules.php:37
Translates between the values a consumer works with and the strings a repository stores.
Definition: Values.php:38

References ILIAS\UI\examples\Layout\Page\Mail\$refinery.

Member Function Documentation

◆ persistent()

ILIAS\KeyValueStorage\Internal\StorageServices::persistent ( array  $namespace)

Storage that survives session boundaries until changed or cleared.

This storage has no subject: it is shared by every user of the installation and only reads rows whose provider and subject are empty. Per-subject state belongs in {

See also
self::persistentFor()}. Encoding a subject into the namespace or the key is not a supported substitute.
Parameters
list<string>$namespace namespace segments; joined with "." internally

Implements ILIAS\KeyValueStorage\Services.

Definition at line 60 of file StorageServices.php.

60 : Store
61 {
62 return $this->store('persistent', new StorageNamespace($namespace), $this->persistent);
63 }
Isolates the keys of one consumer from every other consumer of a storage.
store(string $scope, StorageNamespace $namespace, Repository $repository)
persistent(array $namespace)
Storage that survives session boundaries until changed or cleared.

References ILIAS\KeyValueStorage\Internal\StorageServices\persistent(), and ILIAS\KeyValueStorage\Internal\StorageServices\store().

Referenced by ILIAS\KeyValueStorage\Internal\StorageServices\persistent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ persistentFor()

ILIAS\KeyValueStorage\Internal\StorageServices::persistentFor ( SubjectResolver  $subjects,
array  $namespace 
)

Persistent storage for the subject the resolver names.

Anonymous and any other non-named subject are rejected. The subject is a parameter of the storage, never part of the namespace or the key.

Parameters
list<string>$namespace namespace segments; joined with "." internally
Exceptions

InvalidArgumentException if the resolver does not name a subject, or the subject's provider is not contributed under its name

Implements ILIAS\KeyValueStorage\Services.

Definition at line 65 of file StorageServices.php.

65 : Store
66 {
67 $subject = $subjects->subject();
68 if (!$subject->isNamed()) {
69 throw new \InvalidArgumentException('Persistent subject storage requires a named subject.');
70 }
71 $this->providers->assertRegistered($subject->id());
72
73 return $this->store(
74 $this->subjectScope($subject->id()),
75 new StorageNamespace($namespace),
76 new BoundSubjectRepository($this->subjects, $subject->id())
77 );
78 }

References ILIAS\KeyValueStorage\Internal\StorageServices\store(), ILIAS\KeyValueStorage\Subject\SubjectResolver\subject(), and ILIAS\KeyValueStorage\Internal\StorageServices\subjectScope().

+ Here is the call graph for this function:

◆ purgeSubject()

ILIAS\KeyValueStorage\Internal\StorageServices::purgeSubject ( SubjectId  $subject)

Removes every subject-scoped entry for this subject, in every namespace.

Global installation state from {

See also
self::persistent()} is not touched.
Exceptions

InvalidArgumentException if the subject's provider is not contributed under its name

Implements ILIAS\KeyValueStorage\Services.

Definition at line 80 of file StorageServices.php.

80 : void
81 {
82 $this->providers->assertRegistered($subject);
83 $this->subjects->removeSubject($subject);
84
85 // the stores of the subject must not answer from what they saw before the purge
86 $prefix = $this->subjectScope($subject) . KeyRules::SEPARATOR;
87 foreach (\array_keys($this->stores) as $key) {
88 if (\str_starts_with($key, $prefix)) {
89 unset($this->stores[$key]);
90 }
91 }
92 }

References ILIAS\KeyValueStorage\Internal\KeyRules\SEPARATOR, and ILIAS\KeyValueStorage\Internal\StorageServices\subjectScope().

+ Here is the call graph for this function:

◆ session()

ILIAS\KeyValueStorage\Internal\StorageServices::session ( array  $namespace)

Storage bound to the current user session.

Parameters
list<string>$namespace namespace segments; joined with "." internally

Implements ILIAS\KeyValueStorage\Services.

Definition at line 55 of file StorageServices.php.

55 : Store
56 {
57 return $this->store('session', new StorageNamespace($namespace), $this->session);
58 }
session(array $namespace)
Storage bound to the current user session.

References ILIAS\KeyValueStorage\Internal\StorageServices\session(), and ILIAS\KeyValueStorage\Internal\StorageServices\store().

Referenced by ILIAS\KeyValueStorage\Internal\StorageServices\session().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store()

ILIAS\KeyValueStorage\Internal\StorageServices::store ( string  $scope,
StorageNamespace  $namespace,
Repository  $repository 
)
private

Definition at line 99 of file StorageServices.php.

99 : Store
100 {
101 return $this->stores[$scope . KeyRules::SEPARATOR . $namespace->value()] ??= new NamespacedStore(
102 $namespace,
103 $repository,
104 $this->key_rules,
105 $this->values
106 );
107 }

References ILIAS\KeyValueStorage\Internal\KeyRules\SEPARATOR, and ILIAS\KeyValueStorage\Internal\StorageNamespace\value().

Referenced by ILIAS\KeyValueStorage\Internal\StorageServices\persistent(), ILIAS\KeyValueStorage\Internal\StorageServices\persistentFor(), and ILIAS\KeyValueStorage\Internal\StorageServices\session().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjectScope()

ILIAS\KeyValueStorage\Internal\StorageServices::subjectScope ( SubjectId  $subject)
private

Field Documentation

◆ $key_rules

readonly KeyRules ILIAS\KeyValueStorage\Internal\StorageServices::$key_rules
private

Definition at line 37 of file StorageServices.php.

◆ $stores

array ILIAS\KeyValueStorage\Internal\StorageServices::$stores = []
private

Definition at line 42 of file StorageServices.php.

◆ $values

readonly Values ILIAS\KeyValueStorage\Internal\StorageServices::$values
private

Definition at line 39 of file StorageServices.php.


The documentation for this class was generated from the following file: