ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilGlobalCacheSettings Class Reference

Class ilGlobalCacheSettings. More...

+ Collaboration diagram for ilGlobalCacheSettings:

Public Member Functions

 readFromIniFile (ilIniFile $ilIniFile)
 
 writeToIniFile (ilIniFile $ilIniFile)
 
 activateAll ()
 
 addActivatedComponent ($component)
 
 resetActivatedComponents ()
 
 isComponentActivated ($component)
 
 areAllComponentActivated ()
 
 getService ()
 
 setService ($service)
 
 getActivatedComponents ()
 
 setActivatedComponents ($activated_components)
 
 isActive ()
 
 setActive ($active)
 
 getLogLevel ()
 
 setLogLevel ($log_level)
 
 __toString ()
 

Data Fields

const LOG_LEVEL_FORCED = -1
 
const LOG_LEVEL_NONE = 0
 
const LOG_LEVEL_SHY = 1
 
const LOG_LEVEL_NORMAL = 2
 
const LOG_LEVEL_CHATTY = 3
 
const INI_HEADER_CACHE = 'cache'
 
const INI_FIELD_ACTIVATE_GLOBAL_CACHE = 'activate_global_cache'
 
const INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE = 'global_cache_service_type'
 
const INI_HEADER_CACHE_ACTIVATED_COMPONENTS = 'cache_activated_components'
 
const INI_FIELD_LOG_LEVEL = 'log_level'
 

Protected Member Functions

 checkIniHeader (ilIniFile $ilIniFile)
 
 getLogLevelName ()
 
 lookupLogLevelName ($level)
 

Protected Attributes

 $service = ilGlobalCache::TYPE_STATIC
 
 $activated_components = array()
 
 $active = false
 
 $log_level = self::LOG_LEVEL_NONE
 

Detailed Description

Class ilGlobalCacheSettings.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 10 of file class.ilGlobalCacheSettings.php.

Member Function Documentation

◆ __toString()

ilGlobalCacheSettings::__toString ( )

Definition at line 214 of file class.ilGlobalCacheSettings.php.

References $log_level, $service, getActivatedComponents(), getLogLevelName(), getService(), and ilGlobalCache\lookupServiceClassName().

Referenced by writeToIniFile().

215  {
216  $service = 'Service: ' . ($this->getService() > 0 ? ilGlobalCache::lookupServiceClassName($this->getService()) : 'none');
217  $activated = 'Activated Components: ' . implode(', ', $this->getActivatedComponents());
218  $log_level = 'Log Level: ' . $this->getLogLevelName();
219 
220  return implode("\n", array( '', '', $service, $activated, $log_level, '' ));
221  }
static lookupServiceClassName($service_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ activateAll()

ilGlobalCacheSettings::activateAll ( )

Definition at line 84 of file class.ilGlobalCacheSettings.php.

References addActivatedComponent(), and ilGlobalCache\getAvailableComponents().

85  {
86  foreach (ilGlobalCache::getAvailableComponents() as $comp) {
87  $this->addActivatedComponent($comp);
88  }
89  }
static getAvailableComponents()
+ Here is the call graph for this function:

◆ addActivatedComponent()

ilGlobalCacheSettings::addActivatedComponent (   $component)
Parameters
$component

Definition at line 95 of file class.ilGlobalCacheSettings.php.

Referenced by activateAll(), and readFromIniFile().

96  {
97  $this->activated_components[] = $component;
98  $this->activated_components = array_unique($this->activated_components);
99  }
+ Here is the caller graph for this function:

◆ areAllComponentActivated()

ilGlobalCacheSettings::areAllComponentActivated ( )
Returns
bool

Definition at line 122 of file class.ilGlobalCacheSettings.php.

References ilGlobalCache\getAvailableComponents().

123  {
124  return count($this->activated_components) == count(ilGlobalCache::getAvailableComponents());
125  }
static getAvailableComponents()
+ Here is the call graph for this function:

◆ checkIniHeader()

ilGlobalCacheSettings::checkIniHeader ( ilIniFile  $ilIniFile)
protected
Parameters
ilIniFile$ilIniFile

Definition at line 185 of file class.ilGlobalCacheSettings.php.

References ilIniFile\addGroup(), and ilIniFile\readGroup().

Referenced by readFromIniFile().

186  {
187  if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE)) {
188  $ilIniFile->addGroup(self::INI_HEADER_CACHE);
189  }
190  if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS)) {
191  $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
192  }
193  }
addGroup($a_group_name)
adds a new group public
readGroup($a_group_name)
returns an associative array of the variables in one group public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActivatedComponents()

ilGlobalCacheSettings::getActivatedComponents ( )
Returns
array

Definition at line 149 of file class.ilGlobalCacheSettings.php.

References $activated_components.

Referenced by __toString(), and ilGlobalCache\setup().

+ Here is the caller graph for this function:

◆ getLogLevel()

ilGlobalCacheSettings::getLogLevel ( )
Returns
int

Definition at line 199 of file class.ilGlobalCacheSettings.php.

References $log_level.

Referenced by getLogLevelName(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ getLogLevelName()

ilGlobalCacheSettings::getLogLevelName ( )
protected
Returns
string

Definition at line 227 of file class.ilGlobalCacheSettings.php.

References getLogLevel(), and lookupLogLevelName().

Referenced by __toString().

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

◆ getService()

ilGlobalCacheSettings::getService ( )
Returns
int

Definition at line 131 of file class.ilGlobalCacheSettings.php.

References $service.

Referenced by __toString(), and writeToIniFile().

132  {
133  return $this->service;
134  }
+ Here is the caller graph for this function:

◆ isActive()

ilGlobalCacheSettings::isActive ( )
Returns
boolean

Definition at line 167 of file class.ilGlobalCacheSettings.php.

References $active.

Referenced by readFromIniFile(), and writeToIniFile().

168  {
169  return $this->active;
170  }
+ Here is the caller graph for this function:

◆ isComponentActivated()

ilGlobalCacheSettings::isComponentActivated (   $component)
Parameters
$component
Returns
bool

Definition at line 113 of file class.ilGlobalCacheSettings.php.

Referenced by writeToIniFile().

114  {
115  return in_array($component, $this->activated_components);
116  }
+ Here is the caller graph for this function:

◆ lookupLogLevelName()

ilGlobalCacheSettings::lookupLogLevelName (   $level)
protected
Parameters
$level
Returns
string

Definition at line 238 of file class.ilGlobalCacheSettings.php.

References $r.

Referenced by getLogLevelName().

239  {
240  $r = new ReflectionClass($this);
241  foreach ($r->getConstants() as $k => $v) {
242  if (strpos($k, 'LOG_LEVEL') === 0 and $v == $level) {
243  return $k;
244  }
245  }
246 
247  return '';
248  }
$r
Definition: example_031.php:79
+ Here is the caller graph for this function:

◆ readFromIniFile()

ilGlobalCacheSettings::readFromIniFile ( ilIniFile  $ilIniFile)
Parameters
ilIniFile$ilIniFile

Definition at line 43 of file class.ilGlobalCacheSettings.php.

References addActivatedComponent(), checkIniHeader(), isActive(), ilIniFile\readGroup(), ilIniFile\readVariable(), resetActivatedComponents(), setActive(), setLogLevel(), and setService().

44  {
45  $this->checkIniHeader($ilIniFile);
46  $this->setActive($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE));
47  $this->setService($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE));
48  $this->setLogLevel($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL));
49  if (!$this->isActive()) {
50  $this->resetActivatedComponents();
51  } else {
52  $cache_components = $ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
53  if (is_array($cache_components)) {
54  foreach ($cache_components as $comp => $v) {
55  if ($v) {
56  $this->addActivatedComponent($comp);
57  }
58  }
59  }
60  }
61  }
checkIniHeader(ilIniFile $ilIniFile)
readVariable($a_group, $a_var_name)
reads a single variable from a group public
readGroup($a_group_name)
returns an associative array of the variables in one group public
+ Here is the call graph for this function:

◆ resetActivatedComponents()

ilGlobalCacheSettings::resetActivatedComponents ( )

Definition at line 102 of file class.ilGlobalCacheSettings.php.

Referenced by readFromIniFile().

103  {
104  $this->activated_components = array();
105  }
+ Here is the caller graph for this function:

◆ setActivatedComponents()

ilGlobalCacheSettings::setActivatedComponents (   $activated_components)
Parameters
array$activated_components

Definition at line 158 of file class.ilGlobalCacheSettings.php.

References $activated_components.

159  {
160  $this->activated_components = $activated_components;
161  }

◆ setActive()

ilGlobalCacheSettings::setActive (   $active)
Parameters
boolean$active

Definition at line 176 of file class.ilGlobalCacheSettings.php.

References $active.

Referenced by readFromIniFile().

177  {
178  $this->active = $active;
179  }
+ Here is the caller graph for this function:

◆ setLogLevel()

ilGlobalCacheSettings::setLogLevel (   $log_level)
Parameters
int$log_level

Definition at line 208 of file class.ilGlobalCacheSettings.php.

References $log_level.

Referenced by readFromIniFile().

209  {
210  $this->log_level = $log_level;
211  }
+ Here is the caller graph for this function:

◆ setService()

ilGlobalCacheSettings::setService (   $service)
Parameters
int$service

Definition at line 140 of file class.ilGlobalCacheSettings.php.

References $service.

Referenced by readFromIniFile().

141  {
142  $this->service = $service;
143  }
+ Here is the caller graph for this function:

◆ writeToIniFile()

ilGlobalCacheSettings::writeToIniFile ( ilIniFile  $ilIniFile)
Parameters
ilIniFile$ilIniFile

Definition at line 67 of file class.ilGlobalCacheSettings.php.

References __toString(), ilIniFile\addGroup(), ilGlobalCache\getAvailableComponents(), getLogLevel(), getService(), isActive(), isComponentActivated(), ilGlobalCache\log(), ilIniFile\removeGroup(), ilIniFile\setVariable(), and ilIniFile\write().

68  {
69  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE, $this->isActive() ? '1' : '0');
70  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE, $this->getService());
71  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL, $this->getLogLevel());
72 
73  $ilIniFile->removeGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
74  $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
75  foreach (ilGlobalCache::getAvailableComponents() as $comp) {
76  $ilIniFile->setVariable(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS, $comp, $this->isComponentActivated($comp) ? '1' : '0');
77  }
78  if ($ilIniFile->write()) {
79  ilGlobalCache::log('saved new settings: ' . $this->__toString(), self::LOG_LEVEL_FORCED);
80  }
81  }
setVariable($a_group_name, $a_var_name, $a_var_value)
sets a variable in a group public
write()
save ini-file-data to filesystem private
removeGroup($a_group_name)
removes a group public
static getAvailableComponents()
static log($message, $log_level)
addGroup($a_group_name)
adds a new group public
+ Here is the call graph for this function:

Field Documentation

◆ $activated_components

ilGlobalCacheSettings::$activated_components = array()
protected

◆ $active

ilGlobalCacheSettings::$active = false
protected

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

Referenced by isActive(), and setActive().

◆ $log_level

ilGlobalCacheSettings::$log_level = self::LOG_LEVEL_NONE
protected

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

Referenced by __toString(), getLogLevel(), and setLogLevel().

◆ $service

ilGlobalCacheSettings::$service = ilGlobalCache::TYPE_STATIC
protected

Definition at line 25 of file class.ilGlobalCacheSettings.php.

Referenced by __toString(), getService(), and setService().

◆ INI_FIELD_ACTIVATE_GLOBAL_CACHE

const ilGlobalCacheSettings::INI_FIELD_ACTIVATE_GLOBAL_CACHE = 'activate_global_cache'

Definition at line 18 of file class.ilGlobalCacheSettings.php.

◆ INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE

const ilGlobalCacheSettings::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE = 'global_cache_service_type'

Definition at line 19 of file class.ilGlobalCacheSettings.php.

◆ INI_FIELD_LOG_LEVEL

const ilGlobalCacheSettings::INI_FIELD_LOG_LEVEL = 'log_level'

Definition at line 21 of file class.ilGlobalCacheSettings.php.

◆ INI_HEADER_CACHE

const ilGlobalCacheSettings::INI_HEADER_CACHE = 'cache'

Definition at line 17 of file class.ilGlobalCacheSettings.php.

◆ INI_HEADER_CACHE_ACTIVATED_COMPONENTS

const ilGlobalCacheSettings::INI_HEADER_CACHE_ACTIVATED_COMPONENTS = 'cache_activated_components'

Definition at line 20 of file class.ilGlobalCacheSettings.php.

◆ LOG_LEVEL_CHATTY

const ilGlobalCacheSettings::LOG_LEVEL_CHATTY = 3

◆ LOG_LEVEL_FORCED

const ilGlobalCacheSettings::LOG_LEVEL_FORCED = -1

Definition at line 12 of file class.ilGlobalCacheSettings.php.

Referenced by HTML_Template_IT\init().

◆ LOG_LEVEL_NONE

const ilGlobalCacheSettings::LOG_LEVEL_NONE = 0

Definition at line 13 of file class.ilGlobalCacheSettings.php.

◆ LOG_LEVEL_NORMAL

const ilGlobalCacheSettings::LOG_LEVEL_NORMAL = 2

Definition at line 15 of file class.ilGlobalCacheSettings.php.

Referenced by ilGlobalCache\generateServiceId().

◆ LOG_LEVEL_SHY

const ilGlobalCacheSettings::LOG_LEVEL_SHY = 1

Definition at line 14 of file class.ilGlobalCacheSettings.php.


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