ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\KeyValueStorage\Internal\SubjectProviders Class Reference

The contributed subject providers, keyed by their name. More...

+ Collaboration diagram for ILIAS\KeyValueStorage\Internal\SubjectProviders:

Public Member Functions

 __construct (iterable $providers)
 
 assertRegistered (SubjectId $subject)
 

Private Attributes

array $providers
 

Detailed Description

The contributed subject providers, keyed by their name.

Unique names are checked by the build only, see {

See also
\ILIAS\KeyValueStorage\Setup\SubjectProviderNamesUniqueObjective}.

Definition at line 32 of file SubjectProviders.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\KeyValueStorage\Internal\SubjectProviders::__construct ( iterable  $providers)
Parameters
iterable<SubjectProvider>$providers

Definition at line 40 of file SubjectProviders.php.

41 {
42 $by_name = [];
43 foreach ($providers as $provider) {
44 if (!$provider instanceof SubjectProvider) {
45 throw new \InvalidArgumentException('Expected a subject provider.');
46 }
47 $by_name[$provider->name()] = $provider::class;
48 }
49 $this->providers = $by_name;
50 }

References ILIAS\KeyValueStorage\Internal\SubjectProviders\$providers.

Member Function Documentation

◆ assertRegistered()

ILIAS\KeyValueStorage\Internal\SubjectProviders::assertRegistered ( SubjectId  $subject)
Exceptions

InvalidArgumentException if the subject was not named by the contributed provider of its name

Definition at line 55 of file SubjectProviders.php.

55 : void
56 {
57 $registered = $this->providers[$subject->provider()] ?? null;
58 if ($registered === null) {
59 throw new \InvalidArgumentException(
60 'The subject provider "' . $subject->provider() . '" is not registered, '
61 . 'contribute it via $contribute[' . SubjectProvider::class . '::class].'
62 );
63 }
64 if ($registered !== $subject->providerClass()) {
65 throw new \InvalidArgumentException(
66 'The subject provider "' . $subject->provider() . '" is registered as ' . $registered
67 . ', not as ' . $subject->providerClass() . '.'
68 );
69 }
70 }

References ILIAS\KeyValueStorage\Subject\SubjectId\provider(), and ILIAS\KeyValueStorage\Subject\SubjectId\providerClass().

+ Here is the call graph for this function:

Field Documentation

◆ $providers

array ILIAS\KeyValueStorage\Internal\SubjectProviders::$providers
private

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