ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  {
21  return;
22  }
23 
24  $this->elements = array();
25  $factory = ilADTFactory::getInstance();
26 
27  // convert ADTs to DB bridges
28 
29  foreach($this->getADT()->getElements() as $name => $element)
30  {
31  $this->elements[$name] = $factory->getDBBridgeForInstance($element);
32  $this->elements[$name]->setElementId($name);
33  $this->elements[$name]->setTable($this->getTable());
34  $this->elements[$name]->setPrimary($this->getPrimary());
35  }
36  }
37 
38  public function getElements()
39  {
40  $this->prepareElements();
41  return $this->elements;
42  }
43 
44  public function getElement($a_element_id)
45  {
46  if(array_key_exists($a_element_id, $this->getElements()))
47  {
48  return $this->elements[$a_element_id];
49  }
50  }
51 
52 
53  // properties
54 
55  public function setTable($a_table)
56  {
57  parent::setTable($a_table);
58 
59  if(sizeof($this->elements))
60  {
61  foreach(array_keys($this->getADT()->getElements()) as $name)
62  {
63  $this->elements[$name]->setTable($this->getTable());
64  }
65  }
66  }
67 
68  public function setPrimary(array $a_value)
69  {
70  parent::setPrimary($a_value);
71 
72  if(sizeof($this->elements))
73  {
74  foreach(array_keys($this->getADT()->getElements()) as $name)
75  {
76  $this->elements[$name]->setPrimary($this->getPrimary());
77  }
78  }
79  }
80 
81 
82  // CRUD
83 
84  public function readRecord(array $a_row)
85  {
86  foreach($this->getElements() as $element)
87  {
88  $element->readRecord($a_row);
89  }
90  }
91 
92  public function prepareInsert(array &$a_fields)
93  {
94  foreach($this->getElements() as $element)
95  {
96  $element->prepareInsert($a_fields);
97  }
98  }
99 
100  public function afterInsert()
101  {
102  foreach($this->getElements() as $element)
103  {
104  $element->afterInsert();
105  }
106  }
107 
108  public function afterUpdate()
109  {
110  foreach($this->getElements() as $element)
111  {
112  $element->afterUpdate();
113  }
114  }
115 
116  public function afterDelete()
117  {
118  foreach($this->getElements() as $element)
119  {
120  $element->afterDelete();
121  }
122  }
123 }
124 
125 ?>