ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry Class Reference
+ Inheritance diagram for ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry:
+ Collaboration diagram for ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry:

Public Member Functions

 __construct (array $tasks, array $values)
 
 isRegistered (string $class_name)
 
 newTask (string $class_name)
 
 newValue (string $class_name)
 
 isRegistered (string $class_name)
 
 newTask (string $class_name)
 
 newValue (string $class_name)
 

Private Member Functions

 unique (Task|Value $prototype)
 

Private Attributes

array $tasks = []
 
array $values = []
 

Detailed Description

Definition at line 26 of file BasicRegistry.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry::__construct ( array  $tasks,
array  $values 
)
Parameters
Task[]$tasks
Value[]$values

Definition at line 42 of file BasicRegistry.php.

43 {
44 foreach ($tasks as $task) {
45 $this->tasks[$this->unique($task)] = $task;
46 }
47 foreach ($values as $value) {
48 $this->values[$this->unique($value)] = $value;
49 }
50 }

References ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry\$tasks, ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry\$values, and ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry\unique().

+ Here is the call graph for this function:

Member Function Documentation

◆ isRegistered()

ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry::isRegistered ( string  $class_name)

Implements ILIAS\BackgroundTasks\Registry\Registry.

Definition at line 52 of file BasicRegistry.php.

52 : bool
53 {
54 $class_name = ltrim($class_name, '\\');
55 return isset($this->tasks[$class_name]) || isset($this->values[$class_name]);
56 }

◆ newTask()

ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry::newTask ( string  $class_name)
Exceptions

OutOfBoundsException if no task with this class name is registered

Implements ILIAS\BackgroundTasks\Registry\Registry.

Definition at line 58 of file BasicRegistry.php.

58 : Task
59 {
60 $class_name = ltrim($class_name, '\\');
61 if (!isset($this->tasks[$class_name])) {
62 throw new \OutOfBoundsException("No task $class_name is registered.");
63 }
64 return clone $this->tasks[$class_name];
65 }

◆ newValue()

ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry::newValue ( string  $class_name)
Exceptions

OutOfBoundsException if no value with this class name is registered

Implements ILIAS\BackgroundTasks\Registry\Registry.

Definition at line 67 of file BasicRegistry.php.

67 : Value
68 {
69 $class_name = ltrim($class_name, '\\');
70 if (!isset($this->values[$class_name])) {
71 throw new \OutOfBoundsException("No value $class_name is registered.");
72 }
73 return clone $this->values[$class_name];
74 }

◆ unique()

ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry::unique ( Task|Value  $prototype)
private

Definition at line 76 of file BasicRegistry.php.

76 : string
77 {
78 $class_name = $prototype::class;
79 if (isset($this->tasks[$class_name]) || isset($this->values[$class_name])) {
80 throw new \LogicException("$class_name is contributed more than once.");
81 }
82 return $class_name;
83 }

Referenced by ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry\__construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $tasks

array ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry::$tasks = []
private

◆ $values

array ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry::$values = []
private

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