ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCachedCtrl.php
Go to the documentation of this file.
1 <?php
2 
10 {
14  protected $db;
15 
16 
20  protected $changed = false;
24  protected static $instance;
28  protected $loaded = false;
32  protected $module_classes = array();
36  protected $service_classes = array();
40  protected $ctrl_calls = array();
44  protected $ctrl_classfile = array();
49 
50 
54  public static function getInstance()
55  {
56  if (!isset(self::$instance)) {
58  $cached_obj = $global_cache->get('ilCachedCtrl');
59  if ($cached_obj instanceof ilCachedCtrl) {
60  self::$instance = $cached_obj;
61  } else {
62  self::$instance = new self();
63  $global_cache->set('ilCachedCtrl', self::$instance);
64  }
65  }
66 
67  return self::$instance;
68  }
69 
70 
71  public static function flush()
72  {
74  self::$instance = null;
75  }
76 
77 
81  public function isActive()
82  {
84  }
85 
86 
87  protected function __construct()
88  {
89  global $DIC;
90 
91  $this->db = $DIC->database();
93  $this->readFromDB();
94  }
95 
96 
97  public function __destruct()
98  {
99  if ($this->changed) {
100  $this->global_cache->set('ilCachedCtrl', $this);
101  }
102  }
103 
104 
105  protected function readFromDB()
106  {
107  $ilDB = $this->db;
111  $set = $ilDB->query('SELECT module_class.*, LOWER(module_class.class) lower_class FROM module_class');
112  while ($rec = $ilDB->fetchAssoc($set)) {
113  $this->module_classes[$rec['lower_class']] = $rec;
114  }
115  $set = $ilDB->query('SELECT service_class.*, LOWER(service_class.class) lower_class FROM service_class');
116  while ($rec = $ilDB->fetchAssoc($set)) {
117  $this->service_classes[$rec['lower_class']] = $rec;
118  }
119  $set = $ilDB->query('SELECT * FROM ctrl_calls');
120  while ($rec = $ilDB->fetchAssoc($set)) {
121  $this->ctrl_calls[$rec['parent']][] = $rec;
122  }
123  $set = $ilDB->query('SELECT * FROM ctrl_classfile');
124  while ($rec = $ilDB->fetchAssoc($set)) {
125  $this->ctrl_classfile[$rec['cid']] = $rec;
126  $this->ctrl_classfile_parent[$rec['class']] = $rec;
127  }
128  }
129 
130 
136  public function lookupModuleClass($class)
137  {
138  return $this->module_classes[$class];
139  }
140 
141 
147  public function lookupServiceClass($class)
148  {
149  return $this->service_classes[$class];
150  }
151 
152 
158  public function lookupCid($cid)
159  {
160  return $this->ctrl_classfile[$cid];
161  }
162 
163 
169  public function lookupCall($parent)
170  {
171  if (is_array($this->ctrl_calls[$parent])) {
172  return $this->ctrl_calls[$parent];
173  } else {
174  return array();
175  }
176  }
177 
178 
184  public function lookupClassFile($class)
185  {
186  return $this->ctrl_classfile_parent[$class];
187  }
188 
189 
193  public function getLoaded()
194  {
195  return $this->loaded;
196  }
197 
198 
202  public function setLoaded($loaded)
203  {
204  $this->loaded = $loaded;
205  }
206 
207 
211  public function setCtrlCalls($ctrl_calls)
212  {
213  $this->ctrl_calls = $ctrl_calls;
214  }
215 
216 
220  public function getCtrlCalls()
221  {
222  return $this->ctrl_calls;
223  }
224 
225 
230  {
231  $this->ctrl_classfile = $ctrl_classfile;
232  }
233 
234 
238  public function getCtrlClassfile()
239  {
240  return $this->ctrl_classfile;
241  }
242 
243 
248  {
249  $this->module_classes = $module_classes;
250  }
251 
252 
256  public function getModuleClasses()
257  {
258  return $this->module_classes;
259  }
260 
261 
266  {
267  $this->service_classes = $service_classes;
268  }
269 
270 
274  public function getServiceClasses()
275  {
276  return $this->service_classes;
277  }
278 
279 
284  {
285  $this->ctrl_classfile_parent = $ctrl_classfile_parent;
286  }
287 
288 
292  public function getCtrlClassfileParent()
293  {
295  }
296 
297 
304  public function __sleep()
305  {
306  return [
307  'changed',
308  'loaded',
309  'module_classes',
310  'service_classes',
311  'ctrl_calls',
312  'ctrl_classfile',
313  'ctrl_classfile_parent'
314  ];
315  }
316 
317 
321  public function __wakeup()
322  {
323  global $DIC;
324 
325  $this->db = $DIC->database();
326  }
327 }
setCtrlClassfile($ctrl_classfile)
__sleep()
Declares all fields which should be serialized by php.
global $DIC
Definition: saml.php:7
setCtrlCalls($ctrl_calls)
static getInstance($component)
lookupServiceClass($class)
Create styles array
The data for the language used.
setCtrlClassfileParent($ctrl_classfile_parent)
__wakeup()
Restore database connection.
global $ilDB
setServiceClasses($service_classes)
setModuleClasses($module_classes)
Class ilCachedCtrl.