ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCachedCtrl.php
Go to the documentation of this file.
1 <?php
2 
9 class ilCachedCtrl {
10 
14  protected $changed = false;
18  protected static $instance;
22  protected $loaded = false;
26  protected $module_classes = array();
30  protected $service_classes = array();
34  protected $ctrl_calls = array();
38  protected $ctrl_classfile = array();
42  protected $ctrl_classfile_parent = array();
43 
44 
48  public static function getInstance() {
49  if (!isset(self::$instance)) {
51  $cached_obj = $global_cache->get('ilCachedCtrl');
52  if ($cached_obj instanceof ilCachedCtrl) {
53  self::$instance = $cached_obj;
54  } else {
55  self::$instance = new self();
56  $global_cache->set('ilCachedCtrl', self::$instance);
57  }
58  }
59 
60  return self::$instance;
61  }
62 
63 
64  public static function flush() {
66  self::$instance = NULL;
67  }
68 
69 
73  public function isActive() {
75  }
76 
77 
78  protected function __construct() {
80  $this->readFromDB();
81  }
82 
83 
84  public function __destruct() {
85  if ($this->changed) {
86  $this->global_cache->set('ilCachedCtrl', $this);
87  }
88  }
89 
90 
91  protected function readFromDB() {
92  global $ilDB;
96  $set = $ilDB->query('SELECT module_class.*, LOWER(module_class.class) lower_class FROM module_class');
97  while ($rec = $ilDB->fetchAssoc($set)) {
98  $this->module_classes[$rec['lower_class']] = $rec;
99  }
100  $set = $ilDB->query('SELECT service_class.*, LOWER(service_class.class) lower_class FROM service_class');
101  while ($rec = $ilDB->fetchAssoc($set)) {
102  $this->service_classes[$rec['lower_class']] = $rec;
103  }
104  $set = $ilDB->query('SELECT * FROM ctrl_calls');
105  while ($rec = $ilDB->fetchAssoc($set)) {
106  $this->ctrl_calls[$rec['parent']][] = $rec;
107  }
108  $set = $ilDB->query('SELECT * FROM ctrl_classfile');
109  while ($rec = $ilDB->fetchAssoc($set)) {
110  $this->ctrl_classfile[$rec['cid']] = $rec;
111  $this->ctrl_classfile_parent[$rec['class']] = $rec;
112  }
113  }
114 
115 
121  public function lookupModuleClass($class) {
122  return $this->module_classes[$class];
123  }
124 
125 
131  public function lookupServiceClass($class) {
132  return $this->service_classes[$class];
133  }
134 
135 
141  public function lookupCid($cid) {
142  return $this->ctrl_classfile[$cid];
143  }
144 
145 
151  public function lookupCall($parent) {
152  if (is_array($this->ctrl_calls[$parent])) {
153  return $this->ctrl_calls[$parent];
154  } else {
155  return array();
156  }
157  }
158 
159 
165  public function lookupClassFile($class) {
166  return $this->ctrl_classfile_parent[$class];
167  }
168 
169 
173  public function getLoaded() {
174  return $this->loaded;
175  }
176 
177 
181  public function setLoaded($loaded) {
182  $this->loaded = $loaded;
183  }
184 
185 
189  public function setCtrlCalls($ctrl_calls) {
190  $this->ctrl_calls = $ctrl_calls;
191  }
192 
193 
197  public function getCtrlCalls() {
198  return $this->ctrl_calls;
199  }
200 
201 
206  $this->ctrl_classfile = $ctrl_classfile;
207  }
208 
209 
213  public function getCtrlClassfile() {
214  return $this->ctrl_classfile;
215  }
216 
217 
222  $this->module_classes = $module_classes;
223  }
224 
225 
229  public function getModuleClasses() {
230  return $this->module_classes;
231  }
232 
233 
238  $this->service_classes = $service_classes;
239  }
240 
241 
245  public function getServiceClasses() {
246  return $this->service_classes;
247  }
248 
249 
254  $this->ctrl_classfile_parent = $ctrl_classfile_parent;
255  }
256 
257 
261  public function getCtrlClassfileParent() {
263  }
264 }
265 
266 ?>