ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBuddySystemRelationStateFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected static ?self $instance = null;
29 protected static ?array $validStates = null;
30
31 public function __construct(protected ilLanguage $lng)
32 {
33 }
34
35 public static function getInstance(?ilLanguage $lng = null): self
36 {
37 global $DIC;
38
39 if (null === self::$instance) {
40 $lng ??= $DIC['lng'];
41
42 self::$instance = new self($lng);
43 }
44
45 return self::$instance;
46 }
47
48 public function reset(): void
49 {
50 self::$instance = null;
51 }
52
57 public function getValidStates(): array
58 {
59 return self::$validStates ?? (self::$validStates = [
64 ]);
65 }
66
71 {
72 foreach ($this->getValidStates() as $state) {
73 if ($state->isInitial()) {
74 return $state;
75 }
76 }
77
78 throw new ilBuddySystemException('Could not find an initial state class');
79 }
80
82 {
83 $stateClass = $state::class;
84 $class = $stateClass . 'TableFilterMapper';
85
86 return new $class($this->lng, $state);
87 }
88
90 int $ownerId,
93 $stateClass = $relation->getState()::class;
94 $class = $stateClass . 'ButtonRenderer';
95
96 return new $class($ownerId, $relation);
97 }
98}
$relation
Class ilBuddySystemException.
getTableFilterStateMapper(ilBuddySystemRelationState $state)
getStateButtonRendererByOwnerAndRelation(int $ownerId, ilBuddySystemRelation $relation)
Class ilBuddySystemRelation.
language handling
Interface ilBuddySystemRelationState.
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26