ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilGlobalVirtualSkillTree.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
24 
30 {
31  protected bool $root_node_processed = false;
35 
36  public function __construct()
37  {
38  global $DIC;
39 
41  $this->skill_tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
42  $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
43  $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
44  }
45 
49  public function getRootNode(): array
50  {
51  $root_id = 0;
52  $root_node = $this->tree->getNodeData($root_id);
53 
54  $root_node["id"] = 0;
55  $root_node["parent"] = 0;
56  $root_node["depth"] = 0;
57  $root_node["obj_id"] = 0;
58 
59  return $root_node;
60  }
61 
65  public function getChildsOfNode(string $a_parent_id): array
66  {
67  if ($a_parent_id === "0") {
68  $childs = [];
69  $trees = $this->skill_tree_manager->getTrees();
70  foreach ($trees as $obj_tree) {
71  $tree = $this->skill_tree_factory->getTreeById($obj_tree->getId());
73  $data["id"] = $data["child"];
74  $childs[] = $data;
75  }
76  return $childs;
77  } else {
78  $parent_id_parts = explode(":", $a_parent_id);
79  $parent_skl_tree_id = (int) $parent_id_parts[0];
80  $tree_id = $this->tree_repo->getTreeIdForNodeId($parent_skl_tree_id);
81  $this->tree = $this->skill_tree_factory->getTreeById($tree_id);
82  return parent::getChildsOfNode($a_parent_id);
83  }
84  }
85 
89  public function getSubTreeForTreeId(string $a_tree_id): array
90  {
91  return array_merge(
92  [$this->getNode($a_tree_id)],
93  $this->__getSubTreeRec($a_tree_id, false)
94  );
95  }
96 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
getNode(string $a_vtree_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__getSubTreeRec(string $id, bool $a_only_basic)