ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Dropdown.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2017 Alexander Killing <killing@leifos.de> Extended GPL, see docs/LICENSE */
4 
6 
7 use ILIAS\UI\Component as C;
12 
16 abstract class Dropdown implements C\Dropdown\Dropdown
17 {
18  use ComponentHelper;
20  use Triggerer;
21 
25  protected $label;
26 
30  protected $aria_label;
31 
35  protected $items;
36 
41  public function __construct($items)
42  {
43  $this->items = $items;
44  }
45 
49  public function getLabel()
50  {
51  return $this->label;
52  }
53 
57  public function getAriaLabel()
58  {
59  return $this->aria_label;
60  }
61 
65  public function getItems()
66  {
67  return $this->items;
68  }
69 
73  public function withLabel($label)
74  {
75  $this->checkStringArg("label", $label);
76  $clone = clone $this;
77  $clone->label = $label;
78  return $clone;
79  }
80 
84  public function withAriaLabel($label)
85  {
86  $this->checkStringArg("label", $label);
87  $clone = clone $this;
88  $clone->aria_label = $label;
89  return $clone;
90  }
91 
95  public function withOnClick(Signal $signal)
96  {
97  return $this->withTriggeredSignal($signal, 'click');
98  }
99 
103  public function appendOnClick(Signal $signal)
104  {
105  return $this->appendTriggeredSignal($signal, 'click');
106  }
107 
111  public function withOnHover(Signal $signal)
112  {
113  return $this->withTriggeredSignal($signal, 'hover');
114  }
115 
119  public function appendOnHover(Signal $signal)
120  {
121  return $this->appendTriggeredSignal($signal, 'hover');
122  }
123 }
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.
appendTriggeredSignal(Component\Signal $signal, $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:31
__construct($items)
Dropdown constructor.
Definition: Dropdown.php:41
This implements commonalities between different types of Dropdowns.
Definition: Dropdown.php:16
withTriggeredSignal(Component\Signal $signal, $event)
Add a triggered signal, replacing any other signals registered on the same event. ...
Definition: Triggerer.php:48