ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilGlobalVirtualSkillTree.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
29 {
30  protected bool $root_node_processed = false;
34 
35  public function __construct()
36  {
37  global $DIC;
38 
40  $this->skill_tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
41  $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
42  $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
43  }
44 
48  public function getRootNode(): array
49  {
50  $root_id = 0;
51  $root_node = $this->tree->getNodeData($root_id);
52 
53  $root_node["id"] = 0;
54  $root_node["parent"] = 0;
55  $root_node["depth"] = 0;
56  $root_node["obj_id"] = 0;
57 
58  return $root_node;
59  }
60 
64  public function getChildsOfNode(string $a_parent_id): array
65  {
66  if ($a_parent_id === "0") {
67  $childs = [];
68  $trees = $this->skill_tree_manager->getTrees();
69  foreach ($trees as $obj_tree) {
70  $tree = $this->skill_tree_factory->getTreeById($obj_tree->getId());
72  $data["id"] = $data["child"];
73  $childs[] = $data;
74  }
75  return $childs;
76  } else {
77  $parent_id_parts = explode(":", $a_parent_id);
78  $parent_skl_tree_id = (int) $parent_id_parts[0];
79  $tree_id = $this->tree_repo->getTreeIdForNodeId($parent_skl_tree_id);
80  $this->tree = $this->skill_tree_factory->getTreeById($tree_id);
81  return parent::getChildsOfNode($a_parent_id);
82  }
83  }
84 
88  public function getSubTreeForTreeId(string $a_tree_id): array
89  {
90  return array_merge(
91  [$this->getNode($a_tree_id)],
92  $this->__getSubTreeRec($a_tree_id, false)
93  );
94  }
95 }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
global $DIC
Definition: shib_login.php:22
getNode(string $a_vtree_id)
__construct(Container $dic, ilPlugin $plugin)
__getSubTreeRec(string $id, bool $a_only_basic)