ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionLifecycle.php
Go to the documentation of this file.
1<?php
2
25{
26 public const DRAFT = 'draft';
27 public const REVIEW = 'review';
28 public const REJECTED = 'rejected';
29 public const FINAL = 'final';
30 public const SHARABLE = 'sharable';
31 public const OUTDATED = 'outdated';
32
33 protected string $identifier;
34
35 private function __construct()
36 {
38 }
39
40 public function getIdentifier(): string
41 {
42 return $this->identifier;
43 }
44
45 private function setIdentifier(string $identifier): void
46 {
47 $this->identifier = $identifier;
48 }
49
53 public function getValidIdentifiers(): array
54 {
56 }
57
58 public function getMappedLomLifecycle(): string
59 {
60 switch ($this->getIdentifier()) {
61 case self::OUTDATED:
63
64 case self::SHARABLE:
65 case self::FINAL:
67
68 case self::REJECTED:
69 case self::REVIEW:
70 case self::DRAFT:
71 default:
73 }
74 }
75
76 public function getTranslation(ilLanguage $lng): string
77 {
78 return $this->getTranslationByIdentifier($lng, $this->getIdentifier());
79 }
80
81 private function getTranslationByIdentifier(ilLanguage $lng, string $identifier): string
82 {
83 switch ($identifier) {
84 case self::DRAFT:
85 return $lng->txt('qst_lifecycle_draft');
86
87 case self::REVIEW:
88 return $lng->txt('qst_lifecycle_review');
89
90 case self::REJECTED:
91 return $lng->txt('qst_lifecycle_rejected');
92
93 case self::FINAL:
94 return $lng->txt('qst_lifecycle_final');
95
96 case self::SHARABLE:
97 return $lng->txt('qst_lifecycle_sharable');
98
99 case self::OUTDATED:
100 return $lng->txt('qst_lifecycle_outdated');
101
102 default:
103 return '';
104 }
105 }
106
111 public function getSelectOptions(ilLanguage $lng): array
112 {
113 $selectOptions = [];
114
115 foreach ($this->getValidIdentifiers() as $identifier) {
116 $selectOptions[$identifier] = $this->getTranslationByIdentifier($lng, $identifier);
117 }
118
119 return $selectOptions;
120 }
121
126 private function validateIdentifier($identifier): void
127 {
128 if (!in_array($identifier, $this->getValidIdentifiers(), true)) {
130 'Invalid ilias lifecycle given: ' . $identifier
131 );
132 }
133 }
134
140 public static function getInstance($identifier): self
141 {
142 $lifecycle = new self();
143 $lifecycle->validateIdentifier($identifier);
144 $lifecycle->setIdentifier($identifier);
145
146 return $lifecycle;
147 }
148
149 public static function getDraftInstance(): self
150 {
151 $lifecycle = new self();
152 $lifecycle->setIdentifier(self::DRAFT);
153
154 return $lifecycle;
155 }
156}
$lifecycle
getTranslationByIdentifier(ilLanguage $lng, string $identifier)
language handling
global $lng
Definition: privfeed.php:31