ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
KSDocumentationTreeRecursion.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
29{
30 protected Entries $entries;
31 protected URI $parent_uri;
33
34 public function __construct(Entries $entries, URI $parent_uri, string $current_opened_entry_id)
35 {
36 $this->entries = $entries;
37 $this->parent_uri = $parent_uri;
38 $this->current_node = $entries->getRootEntry();
39 if ($current_opened_entry_id) {
40 $this->current_node = $entries->getEntryById($current_opened_entry_id);
41 }
42 }
43
44 public function getChildren($record, $environment = null): array
45 {
49 return $this->entries->getChildrenOfEntry($record->getId());
50 }
51
52 public function build(
53 \ILIAS\UI\Component\Tree\Node\Factory $factory,
54 $record,
55 $environment = null
56 ): \ILIAS\UI\Component\Tree\Node\Node {
60 $is_expanded = ($this->entries->isParentOfEntry($record->getId(), $this->current_node->getId())) ||
61 ($record == $this->entries->getRootEntry());
62 $is_highlited = $this->current_node->getId() == $record->getId();
63
64 return $factory->simple($record->getTitle())
65 ->withLink($this->getNodeUri($record))
66 ->withExpanded($is_expanded)
67 ->withHighlighted($is_highlited);
68 }
69
70 protected function getNodeUri(Entry $a_node): URI
71 {
72 return $this->parent_uri->withParameter('node_id', $a_node->getId());
73 }
74}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
withParameter(string $key, $value)
Get URI with modified parameters.
Definition: URI.php:388
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable.
Stores Information of UI Components parsed from YAML, examples and less files.
Tree Recursion, putting Entries into a Tree.
__construct(Entries $entries, URI $parent_uri, string $current_opened_entry_id)
Interface for mapping data-structures to the Tree.
build(Node\Factory $factory, $record, $environment=null)
Build and return a Node.
getChildren( $record, $environment=null)
Get a list of records (that list can also be empty).
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.