ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
Node.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4/* Copyright (c) 2019 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
5
7
15
19abstract class Node implements INode
20{
23 use Triggerer;
24
28 protected $link;
29
33 protected $label;
34
38 protected $expanded = false;
39
43 protected $highlighted = false;
44
48 protected $subnodes = [];
49
50 public function __construct(string $label, URI $link = null)
51 {
52 $this->label = $label;
53 $this->link = $link;
54 }
55
59 public function getLabel() : string
60 {
61 return $this->label;
62 }
63
67 public function withAdditionalSubnode(INode $node) : INode
68 {
69 $this->subnodes[] = $node;
70 return $this;
71 }
72
76 public function getSubnodes() : array
77 {
78 return $this->subnodes;
79 }
80
84 public function withExpanded(bool $expanded) : INode
85 {
86 $clone = clone $this;
87 $clone->expanded = $expanded;
88 return $clone;
89 }
90
94 public function isExpanded() : bool
95 {
96 return $this->expanded;
97 }
98
102 public function withHighlighted(bool $highlighted) : INode
103 {
104 $clone = clone $this;
105 $clone->highlighted = $highlighted;
106 return $clone;
107 }
108
112 public function isHighlighted() : bool
113 {
114 return $this->highlighted;
115 }
116
120 public function withOnClick(Signal $signal)
121 {
122 return $this->withTriggeredSignal($signal, 'click');
123 }
124
128 public function appendOnClick(Signal $signal)
129 {
130 return $this->appendTriggeredSignal($signal, 'click');
131 }
132
137 public function getLink() : ?URI
138 {
139 return $this->link;
140 }
141}
An exception for terminatinating execution or to throw for unit testing.
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:18
withHighlighted(bool $highlighted)
@inhertidoc
Definition: Node.php:102
appendOnClick(Signal $signal)
@inhertidoc
Definition: Node.php:128
withOnClick(Signal $signal)
@inhertidoc
Definition: Node.php:120
getLink()
Get the URI object that is added as link in the UI.
Definition: Node.php:137
__construct(string $label, URI $link=null)
Definition: Node.php:50
This describes a Tree Node.
Definition: Node.php:16
withTriggeredSignal(Component\Signal $signal, $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:48
appendTriggeredSignal(Component\Signal $signal, $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:31
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.