ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Glyph.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
6 
7 use ILIAS\UI\Component as C;
13 
14 class Glyph implements C\Glyph\Glyph
15 {
16  use ComponentHelper;
18  use Triggerer;
19 
23  private $type;
24 
28  private $action;
29 
33  private $aria_label;
34 
38  private $counters;
39 
43  private $highlighted = false;
44 
45  private static $types = array(self::SETTINGS
46  , self::COLLAPSE
47  , self::EXPAND
48  , self::ADD
49  , self::REMOVE
50  , self::UP
51  , self::DOWN
52  , self::BACK
53  , self::NEXT
54  , self::SORT_ASCENDING
55  , self::SORT_DESCENDING
56  , self::SORT
57  , self::USER
58  , self::MAIL
59  , self::NOTIFICATION
60  , self::TAG
61  , self::NOTE
62  , self::COMMENT
63  , self::BRIEFCASE
64  );
65 
66 
71  public function __construct($type, $aria_label, $action = null)
72  {
73  $this->checkArgIsElement("type", $type, self::$types, "glyph type");
74  $this->checkStringArg("string", $aria_label);
75 
76  if ($action !== null) {
77  $this->checkStringArg("action", $action);
78  }
79  $this->type = $type;
80  $this->aria_label = $aria_label;
81  $this->action = $action;
82  $this->counters = array();
83  $this->highlighted = false;
84  }
85 
89  public function getType()
90  {
91  return $this->type;
92  }
96  public function getAriaLabel()
97  {
98  return $this->aria_label;
99  }
100 
104  public function getAction()
105  {
106  return $this->action;
107  }
108 
112  public function getCounters()
113  {
114  return array_values($this->counters);
115  }
116 
120  public function withCounter(Counter $counter)
121  {
122  $clone = clone $this;
123  $clone->counters[$counter->getType()] = $counter;
124  return $clone;
125  }
126 
130  public function isHighlighted()
131  {
132  return $this->highlighted;
133  }
134 
138  public function withHighlight()
139  {
140  $clone = clone $this;
141  $clone->highlighted = true;
142  return $clone;
143  }
144 
145 
149  public function withOnClick(Signal $signal)
150  {
151  return $this->addTriggeredSignal($signal, 'click');
152  }
153 
157  public function appendOnClick(Signal $signal)
158  {
159  return $this->appendTriggeredSignal($signal, 'click');
160  }
161 }
This tags a counter object.
Definition: Counter.php:10
__construct($type, $aria_label, $action=null)
Definition: Glyph.php:71
checkArgIsElement($which, $value, $array, $name)
Throw an InvalidArgumentException if $value is not an element of array.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
getType()
Get the type of the counter.
addTriggeredSignal(Component\Signal $signal, $event)
Add a triggered signal, replacing any other signals registered on the same event. ...
Definition: Triggerer.php:46
$counter
appendTriggeredSignal(Component\Signal $signal, $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:29
Create styles array
The data for the language used.