ILIAS  release_8 Revision v8.23
class.ilSkillTemplateCategory.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  public function __construct(int $a_id = 0)
28  {
29  parent::__construct($a_id);
30  $this->setType("sctp");
31  }
32 
33  public function copy(): ilSkillTemplateCategory
34  {
35  $sctp = new ilSkillTemplateCategory();
36  $sctp->setTitle($this->getTitle());
37  $sctp->setDescription($this->getDescription());
38  $sctp->setType($this->getType());
39  $sctp->setOrderNr($this->getOrderNr());
40  $sctp->create();
41 
42  return $sctp;
43  }
44 
45  public function delete(): void
46  {
47  $ilDB = $this->db;
48 
49  $sctp_id = $this->getId();
50  $skill_tree = $this->skill_service->internal()->repo()->getTreeRepo()->getTreeForNodeId($sctp_id);
51  $childs = $skill_tree->getChildsByTypeFilter(
52  $sctp_id,
53  ["sktp", "sctp"]
54  );
55  foreach ($childs as $node) {
56  switch ($node["type"]) {
57  case "sktp":
58  $obj = new ilBasicSkillTemplate((int) $node["obj_id"]);
59  $obj->delete();
60  break;
61 
62  case "sctp":
63  $obj = new ilSkillTemplateCategory((int) $node["obj_id"]);
64  $obj->delete();
65  break;
66  }
67  }
68 
69  foreach (\ilSkillTemplateReference::_lookupTrefIdsForTopTemplateId($sctp_id) as $tref_id) {
70  $obj = ilSkillTreeNodeFactory::getInstance($tref_id);
71  $skill_tree = $this->skill_service->internal()->repo()->getTreeRepo()->getTreeForNodeId($tref_id);
72  $node_data = $skill_tree->getNodeData($tref_id);
73  if (is_object($obj)) {
74  $obj->delete();
75  }
76  if ($skill_tree->isInTree($tref_id)) {
77  $skill_tree->deleteTree($node_data);
78  }
79  }
80 
81  $ilDB->manipulate(
82  "DELETE FROM skl_templ_ref WHERE "
83  . " templ_id = " . $ilDB->quote($this->getId(), "integer")
84  );
85 
86  parent::delete();
87  }
88 }
setType(string $a_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTrefIdsForTopTemplateId(int $a_template_id)
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...