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
6namespace ILIAS\UI\Implementation\Component\Tree;
7
8use ILIAS\UI\Component\Tree as ITree;
9use ILIAS\UI\Implementation\Component\ComponentHelper;
10
11/**
12 * Tree Control
13 */
14abstract class Tree implements ITree\Tree
15{
16    use ComponentHelper;
17
18    /**
19     * @var mixed
20     */
21    protected $environment;
22
23    /**
24     * @var mixed
25     */
26    protected $data;
27
28    /**
29     * @var string
30     */
31    protected $label;
32
33    /**
34     * @var TreeRecursion
35     */
36    protected $recursion;
37
38    /**
39     * @var bool
40     */
41    protected $highlight_nodes_on_click = false;
42
43
44    public function __construct(string $label, ITree\TreeRecursion $recursion)
45    {
46        $this->label = $label;
47        $this->recursion = $recursion;
48    }
49
50    /**
51     * @inheritDoc
52     */
53    public function getLabel() : string
54    {
55        return $this->label;
56    }
57
58    /**
59     * @inheritdoc
60     */
61    public function withEnvironment($environment) : ITree\Tree
62    {
63        $clone = clone $this;
64        $clone->environment = $environment;
65        return $clone;
66    }
67
68    /**
69     * @inheritdoc
70     */
71    public function withData($data) : ITree\Tree
72    {
73        $clone = clone $this;
74        $clone->data = $data;
75        return $clone;
76    }
77
78    /**
79     * @inheritdoc
80     */
81    public function getEnvironment()
82    {
83        return $this->environment;
84    }
85
86    /**
87     * @inheritdoc
88     */
89    public function getData()
90    {
91        return $this->data;
92    }
93
94    /**
95     * @inheritdoc
96     */
97    public function getRecursion() : ITree\TreeRecursion
98    {
99        return $this->recursion;
100    }
101
102
103    /**
104     * @inheritdoc
105     */
106    public function withHighlightOnNodeClick(bool $highlight_nodes_on_click) : ITree\Tree
107    {
108        $clone = clone $this;
109        $clone->highlight_nodes_on_click = $highlight_nodes_on_click;
110        return $clone;
111    }
112
113    /**
114     * @inheritdoc
115     */
116    public function getHighlightOnNodeClick() : bool
117    {
118        return $this->highlight_nodes_on_click;
119    }
120}
121