ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilGlobalSkillTree.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
24 
30 {
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 getNodeData(int $a_node_id, ?int $a_tree_pk = null): array
49  {
50  if ($a_node_id == 0) {
51  return $this->getRootNode();
52  }
53  return parent::getNodeData($a_node_id, $a_tree_pk);
54  }
55 
59  public function getRootNode(): array
60  {
61  $root_node = [];
62 
63  $root_node["parent"] = 0;
64  $root_node["depth"] = 0;
65  $root_node["obj_id"] = 0;
66  $root_node["child"] = 0;
67 
68  return $root_node;
69  }
70 
71  public function readRootId(): int
72  {
73  return 0;
74  }
75 
79  public function getChilds(int $a_node_id, string $a_order = "", string $a_direction = "ASC"): array
80  {
81  if ($a_node_id == 0) {
82  $childs = [];
83  $trees = $this->skill_tree_manager->getTrees();
84  foreach ($trees as $obj_tree) {
85  $tree = $this->skill_tree_factory->getTreeById($obj_tree->getId());
86  $data = $tree->getNodeData($tree->readRootId());
87  $data["id"] = $data["child"];
88  $childs[] = $data;
89  }
90  return $childs;
91  } else {
92  return parent::getChilds($a_node_id, $a_order, $a_direction);
93  }
94  }
95 }
ilSkillTreeRepository $tree_repo
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)
global $DIC
Definition: shib_login.php:25
SkillTreeFactory $skill_tree_factory
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
SkillTreeManager $skill_tree_manager
__construct(Container $dic, ilPlugin $plugin)
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")