ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 198 of file class.ilGlobalCacheSettings.php.

198 {
199 $service = 'Service: ' . ($this->getService() > 0 ? ilGlobalCache::lookupServiceClassName($this->getService()) : 'none');
200 $activated = 'Activated Components: ' . implode(', ', $this->getActivatedComponents());
201 $log_level = 'Log Level: ' . $this->getLogLevelName();
202
203 return implode("\n", array( '', '', $service, $activated, $log_level, '' ));
204 }
static lookupServiceClassName($service_type)

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

Referenced by writeToIniFile().

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

◆ activateAll()

ilGlobalCacheSettings::activateAll ( )

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

82 {
83 foreach (ilGlobalCache::getAvailableComponents() as $comp) {
84 $this->addActivatedComponent($comp);
85 }
86 }
static getAvailableComponents()

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

+ Here is the call graph for this function:

◆ addActivatedComponent()

ilGlobalCacheSettings::addActivatedComponent (   $component)
Parameters
$component

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

92 {
93 $this->activated_components[] = $component;
94 $this->activated_components = array_unique($this->activated_components);
95 }

Referenced by activateAll(), and readFromIniFile().

+ Here is the caller graph for this function:

◆ areAllComponentActivated()

ilGlobalCacheSettings::areAllComponentActivated ( )
Returns
bool

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

116 {
117 return count($this->activated_components) == count(ilGlobalCache::getAvailableComponents());
118 }

References ilGlobalCache\getAvailableComponents().

+ Here is the call graph for this function:

◆ checkIniHeader()

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

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

172 {
173 if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE)) {
174 $ilIniFile->addGroup(self::INI_HEADER_CACHE);
175 }
176 if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS)) {
177 $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
178 }
179 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ getActivatedComponents()

ilGlobalCacheSettings::getActivatedComponents ( )
Returns
array

Definition at line 140 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 185 of file class.ilGlobalCacheSettings.php.

185 {
186 return $this->log_level;
187 }

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 210 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 124 of file class.ilGlobalCacheSettings.php.

124 {
125 return $this->service;
126 }

References $service.

Referenced by __toString(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ isActive()

ilGlobalCacheSettings::isActive ( )
Returns
boolean

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

References $active.

Referenced by readFromIniFile(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ isComponentActivated()

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

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

108 {
109 return in_array($component, $this->activated_components);
110 }

Referenced by writeToIniFile().

+ Here is the caller graph for this function:

◆ lookupLogLevelName()

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

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

220 {
221 $r = new ReflectionClass($this);
222 foreach ($r->getConstants() as $k => $v) {
223 if (strpos($k, 'LOG_LEVEL') === 0 AND $v == $level) {
224 return $k;
225 }
226 }
227
228 return '';
229 }
$r
Definition: example_031.php:79

References $r.

Referenced by getLogLevelName().

+ 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.

43 {
44 $this->checkIniHeader($ilIniFile);
45 $this->setActive($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE));
46 $this->setService($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE));
47 $this->setLogLevel($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL));
48 if (!$this->isActive()) {
50 } else {
51 $cache_components = $ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
52 if (is_array($cache_components)) {
53 foreach ($cache_components as $comp => $v) {
54 if ($v) {
55 $this->addActivatedComponent($comp);
56 }
57 }
58 }
59 }
60 }
checkIniHeader(ilIniFile $ilIniFile)

References addActivatedComponent(), checkIniHeader(), isActive(), resetActivatedComponents(), setActive(), setLogLevel(), and setService().

+ Here is the call graph for this function:

◆ resetActivatedComponents()

ilGlobalCacheSettings::resetActivatedComponents ( )

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

98 {
99 $this->activated_components = array();
100 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setActivatedComponents()

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

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

148 {
149 $this->activated_components = $activated_components;
150 }

References $activated_components.

◆ setActive()

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

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

164 {
165 $this->active = $active;
166 }

References $active.

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setLogLevel()

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

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

193 {
194 $this->log_level = $log_level;
195 }

References $log_level.

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setService()

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

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

132 {
133 $this->service = $service;
134 }

References $service.

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ writeToIniFile()

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

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

66 {
67 $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE, $this->isActive() ? '1' : '0');
68 $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE, $this->getService());
69 $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL, $this->getLogLevel());
70
71 $ilIniFile->removeGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
72 $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
73 foreach (ilGlobalCache::getAvailableComponents() as $comp) {
74 $ilIniFile->setVariable(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS, $comp, $this->isComponentActivated($comp) ? '1' : '0');
75 }
76 if ($ilIniFile->write()) {
77 ilGlobalCache::log('saved new settings: ' . $this->__toString(), self::LOG_LEVEL_FORCED);
78 }
79 }
static log($message, $log_level)
write()
save ini-file-data to filesystem @access private

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

+ 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.

◆ 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: