19 declare(strict_types=1);
49 protected array $values
53 public function type():
Type 63 public function values(): \Generator
65 yield
from $this->values;
73 public function txt(
string $key):
string 75 return 'translated suffix';
82 string ...$values_from_vocab
84 return new class ($slot_with_vocab, $values_from_vocab) extends NullCopyrightBridge {
87 protected array $values_from_vocab
91 public function labelsForValues(
95 foreach ($values as $value) {
96 if ($slot !== $this->slot_with_vocab) {
99 if (!in_array($value, $this->values_from_vocab)) {
103 public function __construct(
protected string $value)
107 public function value():
string 112 public function label():
string 114 return 'copyright label for ' . $this->value;
126 string ...$values_from_vocab
127 ): ControlledRepository {
128 return new class ($slot_with_vocab, $only_active, $empty_labels, $values_from_vocab) extends
NullControlledRepository {
131 protected bool $only_active,
132 protected bool $empty_labels,
133 protected array $values_from_vocab
137 public function getLabelsForValues(
142 if ($slot !== $this->slot_with_vocab || $only_active !== $this->only_active) {
145 foreach ($values as $value) {
146 if (!in_array($value, $this->values_from_vocab)) {
151 protected string $value,
152 protected bool $empty_label
156 public function value():
string 161 public function label():
string 163 if ($this->empty_label) {
166 return 'controlled label for ' . $this->value;
177 string ...$values_from_vocab
178 ): StandardRepository {
179 return new class ($slot_with_vocab, $only_active, $values_from_vocab) extends NullStandardRepository {
182 protected bool $only_active,
183 protected array $values_from_vocab
187 public function getLabelsForValues(
193 if ($slot !== $this->slot_with_vocab || $only_active !== $this->only_active) {
196 foreach ($values as $value) {
197 if (!in_array($value, $this->values_from_vocab)) {
201 public function __construct(
protected string $value)
205 public function value():
string 210 public function label():
string 212 return 'standard label for ' . $this->value;
222 string $expected_value,
223 string $expected_label
227 $labelled_value->
value(),
228 'Value of Labelled value ' . $labelled_value->
value() .
' should be ' . $expected_value
232 $labelled_value->
label(),
233 'Label of Labelled value ' . $labelled_value->
label() .
' should be ' . $expected_label
245 $as_array = iterator_to_array($labelled_values);
249 'There should be ' . count($expected) .
' labelled values, not ' . count($as_array)
252 foreach ($as_array as $labelled_value) {
255 $expected[$i][
'value'],
256 $expected[$i][
'label']
265 [
'v1',
true,
true,
true,
'copyright label for v1'],
266 [
'v2',
true,
false,
true,
'copyright label for v2'],
267 [
'v3',
true,
true,
false,
'copyright label for v3'],
268 [
'v4',
true,
false,
false,
'copyright label for v4'],
269 [
'v5',
false,
true,
true,
'controlled label for v5'],
270 [
'v6',
false,
false,
true,
'standard label for v6'],
271 [
'v7',
false,
true,
false,
'controlled label for v7'],
272 [
'v8',
false,
false,
false,
'v8']
276 #[\PHPUnit\Framework\Attributes\DataProvider('singleValueProvider')] 279 bool $is_in_copyright,
280 bool $is_in_controlled,
281 bool $is_in_standard,
282 string $expected_label
286 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
287 ...($is_in_copyright ? [$value] : [])
290 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
293 ...($is_in_controlled ? [$value] : [])
296 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
298 ...($is_in_standard ? [$value] : [])
302 $labels = $presentation->presentableLabels(
304 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
311 [[
'value' => $value,
'label' => $expected_label]]
315 #[\PHPUnit\Framework\Attributes\DataProvider('singleValueProvider')] 318 bool $is_in_copyright,
319 bool $is_in_controlled,
320 bool $is_in_standard,
321 string $expected_label_without_suffix
325 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
326 ...($is_in_copyright ? [$value] : [])
329 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
332 ...($is_in_controlled ? [$value] : [])
335 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
337 ...($is_in_standard ? [$value] : [])
341 $labels = $presentation->presentableLabels(
343 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
348 $suffix = (!$is_in_standard && !$is_in_controlled && !$is_in_copyright) ?
' translated suffix' :
'';
351 [[
'value' => $value,
'label' => $expected_label_without_suffix . $suffix]]
357 $value =
'some value';
361 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
366 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
371 $labels = $presentation->presentableLabels(
373 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
380 [[
'value' => $value,
'label' => $value]]
388 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
393 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
401 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
408 $labels = $presentation->presentableLabels(
410 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
422 [
'value' =>
'contr 2',
'label' =>
'controlled label for contr 2'],
423 [
'value' =>
'cp 1',
'label' =>
'copyright label for cp 1'],
424 [
'value' =>
'something else',
'label' =>
'something else'],
425 [
'value' =>
'stand 2',
'label' =>
'standard label for stand 2'],
426 [
'value' =>
'contr 3',
'label' =>
'controlled label for contr 3']
435 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
441 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
449 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
457 $labels = $presentation->labelsForVocabulary(
461 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
471 [
'value' =>
'v1',
'label' =>
'standard label for v1'],
472 [
'value' =>
'v2',
'label' =>
'standard label for v2'],
473 [
'value' =>
'v3',
'label' =>
'standard label for v3']
482 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
488 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
496 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
504 $labels = $presentation->labelsForVocabulary(
507 Type::CONTROLLED_STRING,
508 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
518 [
'value' =>
'v1',
'label' =>
'controlled label for v1'],
519 [
'value' =>
'v2',
'label' =>
'controlled label for v2'],
520 [
'value' =>
'v3',
'label' =>
'controlled label for v3']
529 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
535 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
543 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
551 $labels = $presentation->labelsForVocabulary(
554 Type::CONTROLLED_VOCAB_VALUE,
555 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
565 [
'value' =>
'v1',
'label' =>
'controlled label for v1'],
566 [
'value' =>
'v2',
'label' =>
'controlled label for v2'],
567 [
'value' =>
'v3',
'label' =>
'controlled label for v3']
576 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
582 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
590 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
598 $labels = $presentation->labelsForVocabulary(
602 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
612 [
'value' =>
'v1',
'label' =>
'copyright label for v1'],
613 [
'value' =>
'v2',
'label' =>
'copyright label for v2'],
614 [
'value' =>
'v3',
'label' =>
'copyright label for v3']
__construct()
Constructor setup ILIAS global object public.