ILIAS  release_7 Revision v7.30-3-g800a261c036
StakeholderARRepository.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
4
7
15{
16
17 public function register(ResourceIdentification $i, ResourceStakeholder $s) : bool
18 {
19 $internal = $this->getInternalID($i, $s);
20 $r = ARStakeholder::find($internal);
21 if (!$r instanceof ARStakeholder) {
22 $r = new ARStakeholder();
23 $r->setInternal($internal);
24 $r->setStakeholderId($s->getId());
25 $r->setStakeholderClass($s->getFullyQualifiedClassName());
26 $r->setIdentification($i->serialize());
27 $r->create();
28 }
29 return true;
30 }
31
33 {
34 $internal = $this->getInternalID($i, $s);
35 $r = ARStakeholder::find($internal);
36 if ($r instanceof ARStakeholder) {
37 $r->delete();
38 return true;
39 }
40 return false;
41 }
42
46 public function getStakeholders(ResourceIdentification $i) : array
47 {
48 $stakeholders = [];
52 foreach (ARStakeholder::where(['identification' => $i->serialize()])->get() as $item) {
53 $class_name = $item->getStakeholderClass();
54 $stakeholders[] = new $class_name();
55 }
56 return $stakeholders;
57 }
58
64 protected function getInternalID(ResourceIdentification $r, ResourceStakeholder $s) : string
65 {
66 return $r->serialize() . '_' . $s->getId();
67 }
68
69 public function getNamesForLocking() : array
70 {
71 return [
72 (new ARStakeholder())->getConnectorContainerName()
73 ];
74 }
75
76 public function preload(array $identification_strings) : void
77 {
78 // noting to to
79 }
80
81 public function populateFromArray(array $data) : void
82 {
83 // noting to to
84 }
85}
static where($where, $operator=null)
An exception for terminatinating execution or to throw for unit testing.
getInternalID(ResourceIdentification $r, ResourceStakeholder $s)
deregister(ResourceIdentification $i, ResourceStakeholder $s)
$i
Definition: metadata.php:24
$data
Definition: storeScorm.php:23