ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCachedComponentData.php
Go to the documentation of this file.
1<?php
2
10{
11
15 protected $cached_results = array();
19 protected static $instance;
23 protected $changed = false;
27 protected $loaded = false;
31 protected $obj_def_name_to_id = array();
35 protected $obj_def_name_and_type_raw = array();
39 protected $il_component = array();
43 protected $il_object_def = array();
47 protected $il_object_subobj = array();
51 protected $subobj_for_parent = array();
55 protected $grouped_rep_obj_types = array();
59 protected $il_pluginslot_by_comp = array();
63 protected $il_pluginslot_by_id = array();
67 protected $il_pluginslot_by_name = array();
71 protected $il_plugin_by_id = array();
75 protected $il_object_group = array();
79 protected $il_object_sub_type = array();
83 protected $il_plugin_active = array();
87 protected $il_plugin_by_name = array();
88
89
90 protected function __construct()
91 {
93 $this->readFromDB();
94 }
95
96
100 public function getLoaded()
101 {
102 return $this->loaded;
103 }
104
105
109 public function setLoaded($loaded)
110 {
111 $this->loaded = $loaded;
112 }
113
114
115 protected function readFromDB()
116 {
117 global $DIC;
118 $ilDB = $DIC->database();
123 $set = $ilDB->query('SELECT * FROM il_component');
124 while ($rec = $ilDB->fetchAssoc($set)) {
125 $this->il_component[$rec['id']] = $rec;
126 $this->obj_def_name_to_id[$rec['id']] = $rec['name'];
127 $this->obj_def_name_and_type_raw[$rec['type']][$rec['name']] = $rec;
128 }
129
130 $set = $ilDB->query('SELECT * FROM il_object_def');
131 while ($rec = $ilDB->fetchAssoc($set)) {
132 $this->il_object_def[$rec['id']] = $rec;
133 }
134
135 $set = $ilDB->query('SELECT * FROM il_object_subobj');
136 while ($rec = $ilDB->fetchAssoc($set)) {
137 $this->il_object_subobj[] = $rec;
138 $parent = $rec['parent'];
139 $this->subobj_for_parent[$parent][] = $rec;
140 }
141 $set = $ilDB->query('SELECT DISTINCT(id) AS sid, parent, il_object_def.* FROM il_object_def, il_object_subobj WHERE NOT (' . $ilDB->quoteIdentifier('system') . ' = 1) AND NOT (sideblock = 1) AND subobj = id');
142 while ($rec = $ilDB->fetchAssoc($set)) {
143 $this->grouped_rep_obj_types[$rec['parent']][] = $rec;
144 }
145
146 $set = $ilDB->query('SELECT * FROM il_pluginslot');
147 while ($rec = $ilDB->fetchAssoc($set)) {
148 $this->il_pluginslot_by_comp[$rec['component']][] = $rec;
149 $this->il_pluginslot_by_id[$rec['id']] = $rec;
150 $this->il_pluginslot_by_name[$rec['name']] = $rec;
151 }
152
153 $set = $ilDB->query('SELECT * FROM il_plugin');
154 $this->il_plugin_active = array();
155 while ($rec = $ilDB->fetchAssoc($set)) {
156 $this->il_plugin_by_id[$rec['plugin_id']] = $rec;
157 $this->il_plugin_by_name[$rec['name']] = $rec;
158 if ($rec['active'] == 1) {
159 $this->il_plugin_active[$rec['slot_id']][] = $rec;
160 }
161 }
162 $set = $ilDB->query('SELECT * FROM il_object_group');
163 while ($rec = $ilDB->fetchAssoc($set)) {
164 $this->il_object_group[$rec['id']] = $rec;
165 }
166 $set = $ilDB->query('SELECT * FROM il_object_sub_type');
167 while ($rec = $ilDB->fetchAssoc($set)) {
168 $this->il_object_sub_type[$rec['obj_type']][] = $rec;
169 }
170 }
171
172
176 public function getIlComponent()
177 {
178 return $this->il_component;
179 }
180
181
186 {
187 $this->il_component = $il_component;
188 }
189
190
194 public function getObjDefNameAndTypeRaw()
195 {
197 }
198
199
204 {
205 $this->obj_def_name_and_type_raw = $obj_def_name_and_type_raw;
206 }
207
208
212 public function getObjDefNameToId()
213 {
215 }
216
217
222 {
223 $this->obj_def_name_to_id = $obj_def_name_to_id;
224 }
225
226
230 public function getIlObjectDef()
231 {
233 }
234
235
240 {
241 $this->il_object_def = $il_object_def;
242 }
243
244
248 public function getIlObjectSubobj()
249 {
251 }
252
253
258 {
259 $this->il_object_subobj = $il_object_subobj;
260 }
261
262
266 public function getGroupedRepObjTypes()
267 {
269 }
270
271
276 {
277 $this->grouped_rep_obj_types = $grouped_rep_obj_types;
278 }
279
280
284 public function getIlPluginslotByComp()
285 {
287 }
288
289
293 public function setIlPluginslotByComp($il_pluginslot_by_service)
294 {
295 $this->il_pluginslot_by_comp = $il_pluginslot_by_service;
296 }
297
298
302 public function getIlPluginslotById()
303 {
305 }
306
307
312 {
313 $this->il_pluginslot_by_id = $il_pluginslot_by_id;
314 }
315
316
320 public function getIlPluginslotByName()
321 {
323 }
324
325
330 {
331 $this->il_pluginslot_by_name = $il_pluginslot_by_name;
332 }
333
334
338 public function getIlPluginById()
339 {
341 }
342
343
348 {
349 $this->il_plugin_by_id = $il_plugin_by_id;
350 }
351
352
356 public function getIlPluginByName()
357 {
359 }
360
361
366 {
367 $this->il_plugin_by_name = $il_plugin_by_name;
368 }
369
370
374 public function getIlPluginActive()
375 {
377 }
378
379
384 {
385 $this->il_plugin_active = $il_plugin_active;
386 }
387
388
392 public function getIlObjectGroup()
393 {
395 }
396
397
402 {
403 $this->il_object_group = $il_object_group;
404 }
405
406
410 public function getIlObjectSubType()
411 {
413 }
414
415
420 {
421 $this->il_object_sub_type = $il_object_sub_type;
422 }
423
424
428 public static function getInstance()
429 {
430 if (!isset(self::$instance)) {
432 $cached_obj = $global_cache->get('ilCachedComponentData');
433 if ($cached_obj instanceof ilCachedComponentData) {
434 self::$instance = $cached_obj;
435 } else {
436 self::$instance = new self();
437 $global_cache->set('ilCachedComponentData', self::$instance);
438 }
439 }
440
441 return self::$instance;
442 }
443
444
445 public static function flush()
446 {
448 self::$instance = null;
449 }
450
451
457 public function lookupPluginByName($name)
458 {
459 return $this->il_plugin_by_name[$name];
460 }
461
462
468 public function lookupActivePluginsBySlotId($slot_id)
469 {
470 if (is_array($this->il_plugin_active[$slot_id])) {
471 return $this->il_plugin_active[$slot_id];
472 } else {
473 return array();
474 }
475 }
476
477
483 public function lookupSubObjForParent($parent)
484 {
485 if (is_array($parent)) {
486 $index = md5(serialize($parent));
487 if (isset($this->cached_results['subop_par'][$index])) {
488 return $this->cached_results['subop_par'][$index];
489 }
490
491 $return = array();
492 foreach ($parent as $p) {
493 if (is_array($this->subobj_for_parent[$p])) {
494 foreach ($this->subobj_for_parent[$p] as $rec) {
495 $return[] = $rec;
496 }
497 }
498 }
499
500 $this->cached_results['subop_par'][$index] = $return;
501 $this->changed = true;
502
503 return $return;
504 }
505
506 return $this->subobj_for_parent[$parent];
507 }
508
509
516 public function lookCompId($type, $name)
517 {
518 return $this->obj_def_name_and_type_raw[$type][$name]['id'];
519 }
520
521
528 public function lookupCompInfo($type, $name)
529 {
530 if (!$type) {
531 if (isset($this->obj_def_name_and_type_raw['Modules'][$name])) {
532 $type = 'Modules';
533 } else {
534 $type = 'Services';
535 }
536 }
537
538 return $this->obj_def_name_and_type_raw[$type][$name];
539 }
540
541
542 public function __destruct()
543 {
545 if ($this->changed && $ilGlobalCache->isActive()) {
546 $this->changed = false;
547 $ilGlobalCache->set('ilCachedComponentData', $this);
548 }
549 }
550
551
557 public function lookupGroupedRepObj($parent)
558 {
559 if (is_array($parent)) {
560 $index = md5(serialize($parent));
561 if (isset($this->cached_results['grpd_repo'][$index])) {
562 return $this->cached_results['grpd_repo'][$index];
563 }
564
565 $return = array();
566 $sids = array();
567 foreach ($parent as $p) {
568 $s = $this->grouped_rep_obj_types[$p];
569 foreach ($s as $child) {
570 if (!in_array($child['sid'], $sids)) {
571 $sids[] = $child['sid'];
572 $return[] = $child;
573 }
574 }
575 }
576 $this->changed = true;
577 $this->cached_results['grpd_repo'][$index] = $return;
578
579 return $return;
580 } else {
581 return $this->grouped_rep_obj_types[$parent];
582 }
583 }
584
585
591 public function lookupPluginSlotByComponent($component)
592 {
593 if (is_array($this->il_pluginslot_by_comp[$component])) {
594 return $this->il_pluginslot_by_comp[$component];
595 }
596
597 return array();
598 }
599
600
606 public function lookupPluginSlotById($id)
607 {
608 return $this->il_pluginslot_by_id[$id];
609 }
610
611
618 {
619 return $this->il_pluginslot_by_name[$name];
620 }
621
622
626 public function getSubobjForParent()
627 {
629 }
630
631
636 {
637 $this->subobj_for_parent = $subobj_for_parent;
638 }
639}
An exception for terminatinating execution or to throw for unit testing.
Class ilCachedComponentData.
setSubobjForParent($subobj_for_parent)
setIlObjectSubType($il_object_sub_type)
setGroupedRepObjTypes($grouped_rep_obj_types)
setObjDefNameAndTypeRaw($obj_def_name_and_type_raw)
setObjDefNameToId($obj_def_name_to_id)
setIlPluginslotByName($il_pluginslot_by_name)
setIlPluginslotByComp($il_pluginslot_by_service)
setIlPluginslotById($il_pluginslot_by_id)
static getInstance($component)
if($format !==null) $name
Definition: metadata.php:230
$index
Definition: metadata.php:128
$type
global $ilDB
$DIC
Definition: xapitoken.php:46