ILIAS  release_8 Revision v8.24
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;
31 protected static ?array $stateOptions = null;
32 protected ilLanguage $lng;
33
34 public function __construct(ilLanguage $lng)
35 {
36 $this->lng = $lng;
37 }
38
39 public static function getInstance(?ilLanguage $lng = null): self
40 {
41 global $DIC;
42
43 if (null === self::$instance) {
44 $lng = $lng ?? $DIC['lng'];
45
46 self::$instance = new self($lng);
47 }
48
49 return self::$instance;
50 }
51
52 public function reset(): void
53 {
54 self::$instance = null;
55 }
56
61 public function getValidStates(): array
62 {
63 return self::$validStates ?? (self::$validStates = [
68 ]);
69 }
70
76 {
77 foreach ($this->getValidStates() as $state) {
78 if ($state->isInitial()) {
79 return $state;
80 }
81 }
82
83 throw new ilBuddySystemException('Could not find an initial state class');
84 }
85
87 {
88 $stateClass = get_class($state);
89 $class = $stateClass . 'TableFilterMapper';
90
91 return new $class($this->lng, $state);
92 }
93
95 int $ownerId,
96 ilBuddySystemRelation $relation
98 $stateClass = get_class($relation->getState());
99 $class = $stateClass . 'ButtonRenderer';
100
101 return new $class($ownerId, $relation);
102 }
103}
Class ilBuddySystemException.
getTableFilterStateMapper(ilBuddySystemRelationState $state)
getStateButtonRendererByOwnerAndRelation(int $ownerId, ilBuddySystemRelation $relation)
Class ilBuddySystemRelation.
language handling
global $DIC
Definition: feed.php:28
Interface ilBuddySystemRelationState.