19 declare(strict_types=1);
51 return [self::TABLE_NAME, self::TABLE_NAME_REL];
57 $stakeholder_id = $s->getId();
58 $stakeholder_class_name = $s->getFullyQualifiedClassName();
60 if (strlen($stakeholder_id) > 64) {
61 throw new \InvalidArgumentException(
'stakeholder ids MUST be shorter or equal to than 64 characters');
63 if (strlen($stakeholder_class_name) > 250) {
64 throw new \InvalidArgumentException(
65 'stakeholder classnames MUST be shorter or equal to than 250 characters' 69 $r = $this->db->queryF(
70 "SELECT " . self::IDENTIFICATION .
" FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s AND stakeholder_id = %s",
72 [$identification, $stakeholder_id]
75 if (
$r->numRows() === 0) {
80 self::IDENTIFICATION => [
'text', $identification],
81 'stakeholder_id' => [
'text', $stakeholder_id],
86 $r = $this->db->queryF(
87 "SELECT id FROM " . self::TABLE_NAME_REL .
" WHERE id = %s",
91 if (
$r->numRows() === 0) {
95 'id' => [
'text', $stakeholder_id],
96 'class_name' => [
'text', $stakeholder_class_name],
101 $this->cache[$identification][$stakeholder_id] = $s;
108 $this->db->manipulateF(
109 "DELETE FROM " . self::TABLE_NAME .
" WHERE " . self::IDENTIFICATION .
" = %s AND stakeholder_id = %s",
124 if (isset($this->cache[$rid]) && is_array($this->cache[$rid])) {
125 return $this->cache[$rid];
128 $r = $this->db->queryF(
129 "SELECT class_name, stakeholder_id FROM " . self::TABLE_NAME .
" 130 JOIN " . self::TABLE_NAME_REL .
" ON stakeholder_id = id 131 WHERE " . self::IDENTIFICATION .
" = %s",
135 while (
$d = $this->db->fetchAssoc(
$r)) {
139 return $this->cache[$rid] ?? [];
142 public function preload(array $identification_strings): void
144 $r = $this->db->query(
145 "SELECT rid, class_name, stakeholder_id FROM " . self::TABLE_NAME
146 .
" JOIN " . self::TABLE_NAME_REL .
" ON stakeholder_id = id 147 WHERE " . $this->db->in(
148 self::IDENTIFICATION,
149 $identification_strings,
154 while (
$d = $this->db->fetchAssoc(
$r)) {
162 $class_name = $data[
'class_name'];
164 if (class_exists($class_name)) {
165 $stakeholder =
new $class_name();
166 $stakeholders[] = $stakeholder;
167 $this->cache[$data[
'rid']][$data[
'stakeholder_id']] = $stakeholder;
Interface StakeholderDBRepository.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
populateFromArray(array $data)
__construct(protected \ilDBInterface $db)
getStakeholders(ResourceIdentification $i)
Interface StakeholderRepository.
Class ResourceIdentification.
deregister(ResourceIdentification $i, ResourceStakeholder $s)
preload(array $identification_strings)
Interface ResourceStakeholder.