ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTGroupDBBridge.php
Go to the documentation of this file.
1 <?php
2 
3 require_once "Services/ADT/classes/Bridges/class.ilADTDBBridge.php";
4 
6 {
7  protected $elements = []; // [array]
8 
9  protected function isValidADT(ilADT $a_adt)
10  {
11  return ($a_adt instanceof ilADTGroup);
12  }
13 
14 
15  // elements
16 
17  protected function prepareElements()
18  {
19  if (sizeof($this->elements)) {
20  return;
21  }
22 
23  $this->elements = array();
25 
26  // convert ADTs to DB bridges
27 
28  foreach ($this->getADT()->getElements() as $name => $element) {
29  $this->elements[$name] = $factory->getDBBridgeForInstance($element);
30  $this->elements[$name]->setElementId($name);
31  $this->elements[$name]->setTable($this->getTable());
32  $this->elements[$name]->setPrimary($this->getPrimary());
33  }
34  }
35 
36  public function getElements()
37  {
38  $this->prepareElements();
39  return $this->elements;
40  }
41 
42  public function getElement($a_element_id)
43  {
44  if (array_key_exists($a_element_id, $this->getElements())) {
45  return $this->elements[$a_element_id];
46  }
47  }
48 
49 
50  // properties
51 
52  public function setTable($a_table)
53  {
54  parent::setTable($a_table);
55 
56  if (sizeof($this->elements)) {
57  foreach (array_keys($this->getADT()->getElements()) as $name) {
58  $this->elements[$name]->setTable($this->getTable());
59  }
60  }
61  }
62 
63  public function setPrimary(array $a_value)
64  {
65  parent::setPrimary($a_value);
66 
67  if (sizeof($this->elements)) {
68  foreach (array_keys($this->getADT()->getElements()) as $name) {
69  $this->elements[$name]->setPrimary($this->getPrimary());
70  }
71  }
72  }
73 
74 
75  // CRUD
76 
77  public function readRecord(array $a_row)
78  {
79  foreach ($this->getElements() as $element) {
80  $element->readRecord($a_row);
81  }
82  }
83 
84  public function prepareInsert(array &$a_fields)
85  {
86  foreach ($this->getElements() as $element) {
87  $element->prepareInsert($a_fields);
88  }
89  }
90 
91  public function afterInsert()
92  {
93  foreach ($this->getElements() as $element) {
94  $element->afterInsert();
95  }
96  }
97 
98  public function afterUpdate()
99  {
100  foreach ($this->getElements() as $element) {
101  $element->afterUpdate();
102  }
103  }
104 
105  public function afterDelete()
106  {
107  foreach ($this->getElements() as $element) {
108  $element->afterDelete();
109  }
110  }
111 }
$factory
Definition: metadata.php:43
getTable()
Get table name.
getPrimary()
Get primary fields.
static getInstance()
Get singleton.
ADT base class.
Definition: class.ilADT.php:11
ADT DB bridge base class.
prepareInsert(array &$a_fields)