ILIAS  release_8 Revision v8.24
class.ilGlobalVirtualSkillTree.php
Go to the documentation of this file.
1<?php
2
22
28{
29 protected bool $root_node_processed = false;
33
34 public function __construct()
35 {
36 global $DIC;
37
39 $this->skill_tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
40 $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
41 $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
42 }
43
47 public function getRootNode(): array
48 {
49 $root_id = 0;
50 $root_node = $this->tree->getNodeData($root_id);
51
52 $root_node["id"] = 0;
53 $root_node["parent"] = 0;
54 $root_node["depth"] = 0;
55 $root_node["obj_id"] = 0;
56
57 return $root_node;
58 }
59
63 public function getChildsOfNode(string $a_parent_id): array
64 {
65 if ($a_parent_id === "0") {
66 $childs = [];
67 $trees = $this->skill_tree_manager->getTrees();
68 foreach ($trees as $obj_tree) {
69 $tree = $this->skill_tree_factory->getTreeById($obj_tree->getId());
71 $data["id"] = $data["child"];
72 $childs[] = $data;
73 }
74 return $childs;
75 } else {
76 $parent_id_parts = explode(":", $a_parent_id);
77 $parent_skl_tree_id = (int) $parent_id_parts[0];
78 $tree_id = $this->tree_repo->getTreeIdForNodeId($parent_skl_tree_id);
79 $this->tree = $this->skill_tree_factory->getTreeById($tree_id);
80 return parent::getChildsOfNode($a_parent_id);
81 }
82 }
83
87 public function getSubTreeForTreeId(string $a_tree_id): array
88 {
89 return array_merge(
90 [$this->getNode($a_tree_id)],
91 $this->__getSubTreeRec($a_tree_id, false)
92 );
93 }
94}
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getNode(string $a_vtree_id)
__getSubTreeRec(string $id, bool $a_only_basic)
global $DIC
Definition: feed.php:28
Interface ilSkillTreeRepository.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc