ILIAS  release_8 Revision v8.24
ilCachedObjectDefinition Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCachedObjectDefinition:

Public Member Functions

 getIlObjectDef ()
 
 getIlObjectGroup ()
 
 getIlObjectSubType ()
 
 lookupSubObjForParent ($parent)
 
 __destruct ()
 
 lookupGroupedRepObj ($parent)
 

Static Public Member Functions

static getInstance ()
 
static flush ()
 

Protected Member Functions

 __construct ()
 
 readFromDB ()
 

Protected Attributes

ilGlobalCache $global_cache
 
array $cached_results = []
 
bool $changed = false
 
array $il_object_def = []
 
array $subobj_for_parent = []
 
array $grouped_rep_obj_types = []
 
array $il_object_group = []
 
array $il_object_sub_type = []
 

Static Protected Attributes

static ilCachedObjectDefinition $instance = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Cache for object definitions, based on ilGlobalCache.

Definition at line 24 of file class.ilCachedObjectDefinition.php.

Constructor & Destructor Documentation

◆ __construct()

ilCachedObjectDefinition::__construct ( )
protected

Definition at line 37 of file class.ilCachedObjectDefinition.php.

38 {
40 $this->readFromDB();
41 }
static getInstance(?string $component)

References ilGlobalCache\COMP_OBJ_DEF, ilGlobalCache\getInstance(), and readFromDB().

+ Here is the call graph for this function:

◆ __destruct()

ilCachedObjectDefinition::__destruct ( )

Definition at line 173 of file class.ilCachedObjectDefinition.php.

174 {
176 if ($this->changed && $ilGlobalCache->isActive()) {
177 $this->changed = false;
178 $ilGlobalCache->set('ilCachedObjectDefinition', $this);
179 }
180 }

References ilGlobalCache\COMP_OBJ_DEF, and ilGlobalCache\getInstance().

+ Here is the call graph for this function:

Member Function Documentation

◆ flush()

static ilCachedObjectDefinition::flush ( )
static

Definition at line 136 of file class.ilCachedObjectDefinition.php.

136 : void
137 {
139 self::$instance = null;
140 }

References ilGlobalCache\COMP_OBJ_DEF, and ilGlobalCache\getInstance().

+ Here is the call graph for this function:

◆ getIlObjectDef()

ilCachedObjectDefinition::getIlObjectDef ( )

Definition at line 104 of file class.ilCachedObjectDefinition.php.

104 : array
105 {
107 }

References $il_object_def.

◆ getIlObjectGroup()

ilCachedObjectDefinition::getIlObjectGroup ( )

Definition at line 109 of file class.ilCachedObjectDefinition.php.

109 : array
110 {
112 }

References $il_object_group.

◆ getIlObjectSubType()

ilCachedObjectDefinition::getIlObjectSubType ( )

Definition at line 114 of file class.ilCachedObjectDefinition.php.

114 : array
115 {
117 }

References $il_object_sub_type.

◆ getInstance()

static ilCachedObjectDefinition::getInstance ( )
static

Definition at line 119 of file class.ilCachedObjectDefinition.php.

120 {
121 if (!isset(self::$instance)) {
123 $cached_obj = $global_cache->get('ilCachedObjectDefinition');
124 if ($cached_obj instanceof ilCachedObjectDefinition) {
125 self::$instance = $cached_obj;
126 } else {
127 self::$instance = new self();
128 $global_cache->set('ilCachedObjectDefinition', self::$instance);
129 }
130 }
131
132 return self::$instance;
133 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ilCachedObjectDefinition $instance
set(string $key, $value, int $ttl=null)

References $global_cache, $instance, ilGlobalCache\COMP_OBJ_DEF, ilGlobalCache\get(), ilGlobalCache\getInstance(), and ilGlobalCache\set().

Referenced by ilObjectDefinition\getGroupedRepositoryObjectTypes(), and ilObjectDefinition\readDefinitionDataFromCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupGroupedRepObj()

ilCachedObjectDefinition::lookupGroupedRepObj (   $parent)
Parameters
mixed$parent
Returns
mixed

Definition at line 187 of file class.ilCachedObjectDefinition.php.

188 {
189 if (is_array($parent)) {
190 $index = md5(serialize($parent));
191 if (isset($this->cached_results['grpd_repo'][$index])) {
192 return $this->cached_results['grpd_repo'][$index];
193 }
194
195 $return = array();
196 $sids = array();
197 foreach ($parent as $p) {
198 $s = $this->grouped_rep_obj_types[$p];
199 foreach ($s as $child) {
200 if (!in_array($child['sid'], $sids)) {
201 $sids[] = $child['sid'];
202 $return[] = $child;
203 }
204 }
205 }
206 $this->changed = true;
207 $this->cached_results['grpd_repo'][$index] = $return;
208
209 return $return;
210 } else {
211 return $this->grouped_rep_obj_types[$parent] ?? null;
212 }
213 }
$index
Definition: metadata.php:145

References $index.

◆ lookupSubObjForParent()

ilCachedObjectDefinition::lookupSubObjForParent (   $parent)
Parameters
mixed$parent
Returns
mixed

Definition at line 147 of file class.ilCachedObjectDefinition.php.

148 {
149 if (is_array($parent)) {
150 $index = md5(serialize($parent));
151 if (isset($this->cached_results['subop_par'][$index])) {
152 return $this->cached_results['subop_par'][$index];
153 }
154
155 $return = array();
156 foreach ($parent as $p) {
157 if (isset($this->subobj_for_parent[$p]) && is_array($this->subobj_for_parent[$p])) {
158 foreach ($this->subobj_for_parent[$p] as $rec) {
159 $return[] = $rec;
160 }
161 }
162 }
163
164 $this->cached_results['subop_par'][$index] = $return;
165 $this->changed = true;
166
167 return $return;
168 }
169
170 return $this->subobj_for_parent[$parent];
171 }

References $index.

◆ readFromDB()

ilCachedObjectDefinition::readFromDB ( )
protected

Definition at line 44 of file class.ilCachedObjectDefinition.php.

44 : void
45 {
46 global $DIC;
47 $db = $DIC->database();
48
49 $sql =
50 "SELECT id, class_name, component, location, checkbox, inherit, translate, devmode, allow_link," . PHP_EOL
51 . "allow_copy, rbac, `system`, sideblock, default_pos, grp, default_pres_pos, `export`, repository," . PHP_EOL
52 . "workspace, administration, amet, orgunit_permissions, lti_provider, offline_handling" . PHP_EOL
53 . "FROM il_object_def" . PHP_EOL
54 ;
55 $set = $db->query($sql);
56 while ($rec = $db->fetchAssoc($set)) {
57 $this->il_object_def[$rec['id']] = $rec;
58 }
59
60 $sql =
61 "SELECT parent, subobj, mmax" . PHP_EOL
62 . "FROM il_object_subobj" . PHP_EOL
63 ;
64 $set = $db->query($sql);
65 while ($rec = $db->fetchAssoc($set)) {
66 $parent = $rec['parent'];
67 $this->subobj_for_parent[$parent][] = $rec;
68 }
69
70 $sql =
71 "SELECT DISTINCT(id) AS sid, parent, id, class_name, component, location, checkbox, inherit," . PHP_EOL
72 . "translate, devmode, allow_link, allow_copy, rbac, `system`, sideblock, default_pos, grp," . PHP_EOL
73 . "default_pres_pos, `export`, repository, workspace, administration, amet, orgunit_permissions," . PHP_EOL
74 . "lti_provider, offline_handling" . PHP_EOL
75 . "FROM il_object_def, il_object_subobj" . PHP_EOL
76 . "WHERE NOT (" . $db->quoteIdentifier('system') . " = 1)" . PHP_EOL
77 . "AND NOT (sideblock = 1)" . PHP_EOL
78 . "AND subobj = id" . PHP_EOL
79 ;
80 $set = $db->query($sql);
81 while ($rec = $db->fetchAssoc($set)) {
82 $this->grouped_rep_obj_types[$rec['parent']][] = $rec;
83 }
84
85 $sql =
86 "SELECT id, name, default_pres_pos" . PHP_EOL
87 . "FROM il_object_group" . PHP_EOL
88 ;
89 $set = $db->query($sql);
90 while ($rec = $db->fetchAssoc($set)) {
91 $this->il_object_group[$rec['id']] = $rec;
92 }
93
94 $sql =
95 "SELECT obj_type, sub_type, amet" . PHP_EOL
96 . "FROM il_object_sub_type" . PHP_EOL
97 ;
98 $set = $db->query($sql);
99 while ($rec = $db->fetchAssoc($set)) {
100 $this->il_object_sub_type[$rec['obj_type']][] = $rec;
101 }
102 }
global $DIC
Definition: feed.php:28

References $DIC.

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $cached_results

array ilCachedObjectDefinition::$cached_results = []
protected

Definition at line 29 of file class.ilCachedObjectDefinition.php.

◆ $changed

bool ilCachedObjectDefinition::$changed = false
protected

Definition at line 30 of file class.ilCachedObjectDefinition.php.

◆ $global_cache

ilGlobalCache ilCachedObjectDefinition::$global_cache
protected

Definition at line 28 of file class.ilCachedObjectDefinition.php.

Referenced by getInstance().

◆ $grouped_rep_obj_types

array ilCachedObjectDefinition::$grouped_rep_obj_types = []
protected

Definition at line 33 of file class.ilCachedObjectDefinition.php.

◆ $il_object_def

array ilCachedObjectDefinition::$il_object_def = []
protected

Definition at line 31 of file class.ilCachedObjectDefinition.php.

Referenced by getIlObjectDef().

◆ $il_object_group

array ilCachedObjectDefinition::$il_object_group = []
protected

Definition at line 34 of file class.ilCachedObjectDefinition.php.

Referenced by getIlObjectGroup().

◆ $il_object_sub_type

array ilCachedObjectDefinition::$il_object_sub_type = []
protected

Definition at line 35 of file class.ilCachedObjectDefinition.php.

Referenced by getIlObjectSubType().

◆ $instance

ilCachedObjectDefinition ilCachedObjectDefinition::$instance = null
staticprotected

Definition at line 26 of file class.ilCachedObjectDefinition.php.

Referenced by getInstance().

◆ $subobj_for_parent

array ilCachedObjectDefinition::$subobj_for_parent = []
protected

Definition at line 32 of file class.ilCachedObjectDefinition.php.


The documentation for this class was generated from the following file: