ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBuddySystemRelationStateFactory.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
11 protected static $instance;
12
14 protected static $validStates;
15
17 protected $lng;
18
19 public function __construct(ilLanguage $lng)
20 {
21 $this->lng = $lng;
22 }
23
24 public static function getInstance(?ilLanguage $lng = null) : self
25 {
26 global $DIC;
27
28 if (null === self::$instance) {
29 $lng = $lng ?? $DIC['lng'];
30
31 self::$instance = new self($lng);
32 }
33
34 return self::$instance;
35 }
36
41 public function getValidStates() : array
42 {
43 if (null !== self::$validStates) {
44 return self::$validStates;
45 }
46
47 return (self::$validStates = [
52 ]);
53 }
54
60 {
61 foreach ($this->getValidStates() as $state) {
62 if ($state->isInitial()) {
63 return $state;
64 }
65 }
66
67 throw new ilBuddySystemException("Could not find an initial state class");
68 }
69
71 {
72 $stateClass = get_class($state);
73 $class = $stateClass . 'TableFilterMapper';
74
75 return new $class($this->lng, $state);
76 }
77
84 int $ownerId,
85 ilBuddySystemRelation $relation
87 $stateClass = get_class($relation->getState());
88 $class = $stateClass . 'ButtonRenderer';
89
90 return new $class($ownerId, $relation);
91 }
92}
An exception for terminatinating execution or to throw for unit testing.
Class ilBuddySystemException.
Class ilBuddySystemRelationStateFactory.
getTableFilterStateMapper(ilBuddySystemRelationState $state)
getStateButtonRendererByOwnerAndRelation(int $ownerId, ilBuddySystemRelation $relation)
Class ilBuddySystemRelation.
language handling
global $DIC
Definition: goto.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilBuddySystemRelationState.