ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
Boolean.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
29 class Boolean extends Column implements C\Boolean
30 {
31  public function __construct(
32  protected \ilLanguage $lng,
33  string $title,
34  protected string|Icon|Glyph $true_option,
35  protected string|Icon|Glyph $false_option
36  ) {
37  parent::__construct($lng, $title);
38 
39  if (
40  ($true_option instanceof Glyph && $true_option->getAction() !== null)
41  || ($false_option instanceof Glyph && $false_option->getAction() !== null)
42  ) {
43  throw new \LogicException(
44  "If Glyps are used to indicate the state, they MUST NOT have an attached action."
45  );
46  }
47  }
48 
49  public function format($value): string|Icon|Glyph
50  {
51  $this->checkBoolArg('value', $value);
52  return $value ? $this->true_option : $this->false_option;
53  }
54 
58  public function getOrderingLabels(): array
59  {
60  $column_value_true = $this->format(true);
61  $column_value_false = $this->format(false);
62  if($column_value_true instanceof Symbol) {
63  $column_value_true = $column_value_true->getLabel();
64  }
65  if($column_value_false instanceof Symbol) {
66  $column_value_false = $column_value_false->getLabel();
67  }
68  return [
69  $this->asc_label ?? $column_value_true . ' ' . $this->lng->txt('order_option_first'),
70  $this->desc_label ?? $column_value_false . ' ' . $this->lng->txt('order_option_first')
71  ];
72  }
73 }
getAction()
Get the action on the glyph.
This describes a symbol.
Definition: Symbol.php:29
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes how a glyph could be modified during construction of UI.
Definition: Glyph.php:30
__construct(VocabulariesInterface $vocabularies)
$lng
__construct(protected \ilLanguage $lng, string $title, protected string|Icon|Glyph $true_option, protected string|Icon|Glyph $false_option)
Definition: Boolean.php:31