ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Boolean.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
30 class Boolean extends Column implements C\Boolean
31 {
32  public function __construct(
33  protected Language $lng,
34  string $title,
35  protected string|Icon|Glyph $true_option,
36  protected string|Icon|Glyph $false_option
37  ) {
38  parent::__construct($lng, $title);
39 
40  if (
41  ($true_option instanceof Glyph && $true_option->getAction() !== null)
42  || ($false_option instanceof Glyph && $false_option->getAction() !== null)
43  ) {
44  throw new \LogicException(
45  "If Glyps are used to indicate the state, they MUST NOT have an attached action."
46  );
47  }
48  }
49 
50  public function format($value): string|Icon|Glyph
51  {
52  $this->checkBoolArg('value', $value);
53  return $value ? $this->true_option : $this->false_option;
54  }
55 
59  public function getOrderingLabels(): array
60  {
61  $column_value_true = $this->format(true);
62  $column_value_false = $this->format(false);
63  if($column_value_true instanceof Symbol) {
64  $column_value_true = $column_value_true->getLabel();
65  }
66  if($column_value_false instanceof Symbol) {
67  $column_value_false = $column_value_false->getLabel();
68  }
69  return [
70  $this->asc_label ?? $column_value_true . ' ' . $this->lng->txt('order_option_first'),
71  $this->desc_label ?? $column_value_false . ' ' . $this->lng->txt('order_option_first')
72  ];
73  }
74 }
getAction()
Get the action on the glyph.
This describes a symbol.
Definition: Symbol.php:29
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(Container $dic, ilPlugin $plugin)
global $lng
Definition: privfeed.php:31
__construct(protected Language $lng, string $title, protected string|Icon|Glyph $true_option, protected string|Icon|Glyph $false_option)
Definition: Boolean.php:32