ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilGlobalCacheSettings Class Reference

Class ilGlobalCacheSettings. More...

+ Collaboration diagram for ilGlobalCacheSettings:

Public Member Functions

 readFromIniFile (ilIniFile $ilIniFile)
 
 writeToIniFile (ilIniFile $ilIniFile)
 
 addActivatedComponent ($component)
 
 resetActivatedComponents ()
 
 isComponentActivated ($component)
 
 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 183 of file class.ilGlobalCacheSettings.php.

183 {
184 $service = 'Service: ' . ($this->getService() > 0 ? ilGlobalCache::lookupServiceClassName($this->getService()) : 'none');
185 $activated = 'Activated Components: ' . implode(', ', $this->getActivatedComponents());
186 $log_level = 'Log Level: ' . $this->getLogLevelName();
187
188 return implode("\n", array( '', '', $service, $activated, $log_level, '' ));
189 }
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:

◆ addActivatedComponent()

ilGlobalCacheSettings::addActivatedComponent (   $component)
Parameters
$component

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

85 {
86 $this->activated_components[] = $component;
87 $this->activated_components = array_unique($this->activated_components);
88 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ checkIniHeader()

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

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

157 {
158 if (! $ilIniFile->readGroup(self::INI_HEADER_CACHE)) {
159 $ilIniFile->addGroup(self::INI_HEADER_CACHE);
160 }
161 if (! $ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS)) {
162 $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
163 }
164 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ getActivatedComponents()

ilGlobalCacheSettings::getActivatedComponents ( )
Returns
array

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

170 {
171 return $this->log_level;
172 }

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 195 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 109 of file class.ilGlobalCacheSettings.php.

109 {
110 return $this->service;
111 }

References $service.

Referenced by __toString(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ isActive()

ilGlobalCacheSettings::isActive ( )
Returns
boolean

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

101 {
102 return in_array($component, $this->activated_components);
103 }

Referenced by writeToIniFile().

+ Here is the caller graph for this function:

◆ lookupLogLevelName()

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

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

205 {
206 $r = new ReflectionClass($this);
207 foreach ($r->getConstants() as $k => $v) {
208 if (strpos($k, 'LOG_LEVEL') === 0 AND $v == $level) {
209 return $k;
210 }
211 }
212
213 return '';
214 }
$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 91 of file class.ilGlobalCacheSettings.php.

91 {
92 $this->activated_components = array();
93 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setActivatedComponents()

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

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

133 {
134 $this->activated_components = $activated_components;
135 }

References $activated_components.

◆ setActive()

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

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

149 {
150 $this->active = $active;
151 }

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

178 {
179 $this->log_level = $log_level;
180 }

References $log_level.

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setService()

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

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

117 {
118 $this->service = $service;
119 }

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)
static getAvailableComponents()
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: