ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 {
34  protected $true_option;
38  protected $false_option;
39 
40  public function __construct(
42  string $title,
45  ) {
46  parent::__construct($lng, $title);
47 
48  if (
49  ($true_option instanceof Glyph && $true_option->getAction() !== null)
50  || ($false_option instanceof Glyph && $false_option->getAction() !== null)
51  ) {
52  throw new \LogicException(
53  "If Glyps are used to indicate the state, they MUST NOT have an attached action."
54  );
55  }
56  $this->true_option = $true_option;
57  $this->false_option = $false_option;
58  }
59 
60  public function format($value)
61  {
62  $this->checkBoolArg('value', $value);
63  return $value ? $this->true_option : $this->false_option;
64  }
65 
69  public function getOrderingLabels(): array
70  {
71  $column_value_true = $this->format(true);
72  $column_value_false = $this->format(false);
73  if($column_value_true instanceof Symbol) {
74  $column_value_true = $column_value_true->getLabel();
75  }
76  if($column_value_false instanceof Symbol) {
77  $column_value_false = $column_value_false->getLabel();
78  }
79  return [
80  $this->asc_label ?? $column_value_true . ' ' . $this->lng->txt('order_option_first'),
81  $this->desc_label ?? $column_value_false . ' ' . $this->lng->txt('order_option_first')
82  ];
83  }
84 }
This describes a symbol.
Definition: Symbol.php:29
__construct(\ilLanguage $lng, string $title, $true_option, $false_option)
Definition: Boolean.php:40
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(Container $dic, ilPlugin $plugin)