ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\Container\Skills\ContainerSkillDBRepository Class Reference
+ Collaboration diagram for ILIAS\Container\Skills\ContainerSkillDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null, SkillInternalFactoryService $factory_service=null,)
 
 add (int $cont_obj_id, int $skill_id, int $tref_id)
 
 remove (int $cont_obj_id, int $skill_id, int $tref_id)
 
 removeForSkill (int $skill_node_id, bool $is_reference)
 
 getAll (int $cont_obj_id)
 

Protected Member Functions

 getContainerSkillFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
SkillInternalFactoryService $factory_service
 

Detailed Description

Definition at line 24 of file class.ContainerSkillDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Container\Skills\ContainerSkillDBRepository::__construct ( \ilDBInterface  $db = null,
SkillInternalFactoryService  $factory_service = null 
)

Definition at line 29 of file class.ContainerSkillDBRepository.php.

References ILIAS\Container\Skills\ContainerSkillDBRepository\$db, $DIC, and ILIAS\Container\Skills\ContainerSkillDBRepository\$factory_service.

32  {
33  global $DIC;
34 
35  $this->db = ($db) ?: $DIC->database();
36  $this->factory_service = ($factory_service) ?: $DIC->skills()->internalContainer()->factory();
37  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ add()

ILIAS\Container\Skills\ContainerSkillDBRepository::add ( int  $cont_obj_id,
int  $skill_id,
int  $tref_id 
)

Definition at line 39 of file class.ContainerSkillDBRepository.php.

39  : void
40  {
41  $this->db->replace(
42  "cont_skills",
43  [
44  "id" => ["integer", $cont_obj_id],
45  "skill_id" => ["integer", $skill_id],
46  "tref_id" => ["integer", $tref_id]
47  ],
48  []
49  );
50  }

◆ getAll()

ILIAS\Container\Skills\ContainerSkillDBRepository::getAll ( int  $cont_obj_id)
Returns
ContainerSkill[]

Definition at line 76 of file class.ContainerSkillDBRepository.php.

References ILIAS\Container\Skills\ContainerSkillDBRepository\getContainerSkillFromRecord().

76  : array
77  {
78  $skills = [];
79  $set = $this->db->query(
80  "SELECT * FROM cont_skills " .
81  " WHERE id = " . $this->db->quote($cont_obj_id, "integer")
82  );
83 
84  while ($rec = $this->db->fetchAssoc($set)) {
85  $skills[] = $this->getContainerSkillFromRecord($rec);
86  }
87  return $skills;
88  }
+ Here is the call graph for this function:

◆ getContainerSkillFromRecord()

ILIAS\Container\Skills\ContainerSkillDBRepository::getContainerSkillFromRecord ( array  $rec)
protected

Definition at line 90 of file class.ContainerSkillDBRepository.php.

References ILIAS\Repository\int().

Referenced by ILIAS\Container\Skills\ContainerSkillDBRepository\getAll().

90  : ContainerSkill
91  {
92  $rec["skill_id"] = (int) $rec["skill_id"];
93  $rec["tref_id"] = (int) $rec["tref_id"];
94  $rec["id"] = (int) $rec["id"];
95 
96  return $this->factory_service->containerSkill()->skill(
97  $rec["skill_id"],
98  $rec["tref_id"],
99  $rec["id"]
100  );
101  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove()

ILIAS\Container\Skills\ContainerSkillDBRepository::remove ( int  $cont_obj_id,
int  $skill_id,
int  $tref_id 
)

Definition at line 52 of file class.ContainerSkillDBRepository.php.

52  : void
53  {
54  $this->db->manipulate(
55  "DELETE FROM cont_skills WHERE " .
56  " id = " . $this->db->quote($cont_obj_id, "integer") .
57  " AND skill_id = " . $this->db->quote($skill_id, "integer") .
58  " AND tref_id = " . $this->db->quote($tref_id, "integer")
59  );
60  }

◆ removeForSkill()

ILIAS\Container\Skills\ContainerSkillDBRepository::removeForSkill ( int  $skill_node_id,
bool  $is_reference 
)

Definition at line 62 of file class.ContainerSkillDBRepository.php.

62  : void
63  {
64  if (!$is_reference) {
65  $this->db->manipulate("DELETE FROM cont_skills " .
66  " WHERE skill_id = " . $this->db->quote($skill_node_id, "integer"));
67  } else {
68  $this->db->manipulate("DELETE FROM cont_skills " .
69  " WHERE tref_id = " . $this->db->quote($skill_node_id, "integer"));
70  }
71  }

Field Documentation

◆ $db

ilDBInterface ILIAS\Container\Skills\ContainerSkillDBRepository::$db
protected

◆ $factory_service

SkillInternalFactoryService ILIAS\Container\Skills\ContainerSkillDBRepository::$factory_service
protected

The documentation for this class was generated from the following file: