ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Node.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\UI\Implementation\Component\ComponentHelper;
30
34abstract class Node implements INode
35{
36 use ComponentHelper;
38 use Triggerer;
39
43 protected array $subnodes = [];
44 protected ?URI $link = null;
45 protected string $label;
46 protected bool $expanded = false;
47 protected bool $highlighted = false;
48
49 public function __construct(string $label, ?URI $link = null)
50 {
51 $this->label = $label;
52 $this->link = $link;
53 }
54
58 public function getLabel(): string
59 {
60 return $this->label;
61 }
62
66 public function withAdditionalSubnode(INode $node): INode
67 {
68 $this->subnodes[] = $node;
69 return $this;
70 }
71
75 public function getSubnodes(): array
76 {
77 return $this->subnodes;
78 }
79
83 public function withExpanded(bool $expanded): INode
84 {
85 $clone = clone $this;
86 $clone->expanded = $expanded;
87 return $clone;
88 }
89
93 public function isExpanded(): bool
94 {
95 return $this->expanded;
96 }
97
101 public function withHighlighted(bool $highlighted): INode
102 {
103 $clone = clone $this;
104 $clone->highlighted = $highlighted;
105 return $clone;
106 }
107
111 public function isHighlighted(): bool
112 {
113 return $this->highlighted;
114 }
115
119 public function withOnClick(Signal $signal): self
120 {
121 return $this->withTriggeredSignal($signal, 'click');
122 }
123
127 public function appendOnClick(Signal $signal): self
128 {
129 return $this->appendTriggeredSignal($signal, 'click');
130 }
131
135 public function getLink(): ?URI
136 {
137 return $this->link;
138 }
139}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
__construct(string $label, ?URI $link=null)
Definition: Node.php:49
withHighlighted(bool $highlighted)
@inhertidoc
Definition: Node.php:101
appendOnClick(Signal $signal)
@inhertidoc
Definition: Node.php:127
withOnClick(Signal $signal)
@inhertidoc
Definition: Node.php:119
getLink()
Get the URI object that is added as link in the UI.
Definition: Node.php:135
This describes a Tree Node.
Definition: Node.php:31
link(string $caption, string $href, bool $new_viewport=false)
appendTriggeredSignal(C\Signal $signal, string $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:47
withTriggeredSignal(C\Signal $signal, string $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:62
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.