ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
12
16abstract class Dropdown implements C\Dropdown\Dropdown
17{
20 use Triggerer;
21
25 protected $label;
26
30 protected $items;
31
36 public function __construct($items)
37 {
38 $this->items = $items;
39 }
40
44 public function getLabel()
45 {
46 return $this->label;
47 }
48
52 public function getItems()
53 {
54 return $this->items;
55 }
56
60 public function withLabel($label)
61 {
62 $this->checkStringArg("label", $label);
63 $clone = clone $this;
64 $clone->label = $label;
65 return $clone;
66 }
67
71 public function withOnClick(Signal $signal)
72 {
73 return $this->addTriggeredSignal($signal, 'click');
74 }
75
79 public function appendOnClick(Signal $signal)
80 {
81 return $this->appendTriggeredSignal($signal, 'click');
82 }
83
87 public function withOnHover(Signal $signal)
88 {
89 return $this->addTriggeredSignal($signal, 'hover');
90 }
91
95 public function appendOnHover(Signal $signal)
96 {
97 return $this->appendTriggeredSignal($signal, 'hover');
98 }
99}
An exception for terminatinating execution or to throw for unit testing.
This implements commonalities between different types of Dropdowns.
Definition: Dropdown.php:17
__construct($items)
Dropdown constructor.
Definition: Dropdown.php:36
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:29
addTriggeredSignal(Component\Signal $signal, $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:46
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.