ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlobalCacheSettings Class Reference

Class ilGlobalCacheSettings. More...

+ Inheritance diagram for ilGlobalCacheSettings:
+ 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 12 of file class.ilGlobalCacheSettings.php.

Member Function Documentation

◆ __toString()

ilGlobalCacheSettings::__toString ( )

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

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

Referenced by writeToIniFile().

217  {
218  $service = 'Service: ' . ($this->getService() > 0 ? ilGlobalCache::lookupServiceClassName($this->getService()) : 'none');
219  $activated = 'Activated Components: ' . implode(', ', $this->getActivatedComponents());
220  $log_level = 'Log Level: ' . $this->getLogLevelName();
221 
222  return implode("\n", array( '', '', $service, $activated, $log_level, '' ));
223  }
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 86 of file class.ilGlobalCacheSettings.php.

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

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

◆ addActivatedComponent()

ilGlobalCacheSettings::addActivatedComponent (   $component)
Parameters
$component

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

Referenced by activateAll(), and readFromIniFile().

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

◆ areAllComponentActivated()

ilGlobalCacheSettings::areAllComponentActivated ( )
Returns
bool

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

References ilGlobalCache\getAvailableComponents().

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

◆ checkIniHeader()

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

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

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

Referenced by readFromIniFile().

188  {
189  if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE)) {
190  $ilIniFile->addGroup(self::INI_HEADER_CACHE);
191  }
192  if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS)) {
193  $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
194  }
195  }
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 151 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 201 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 229 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 133 of file class.ilGlobalCacheSettings.php.

References $service.

Referenced by __toString(), and writeToIniFile().

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

◆ isActive()

ilGlobalCacheSettings::isActive ( )
Returns
boolean

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

References $active.

Referenced by readFromIniFile(), and writeToIniFile().

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

◆ isComponentActivated()

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

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

Referenced by writeToIniFile().

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

◆ lookupLogLevelName()

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

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

Referenced by getLogLevelName().

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

◆ readFromIniFile()

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

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

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

46  {
47  $this->checkIniHeader($ilIniFile);
48  $this->setActive($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE));
49  $this->setService($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE));
50  $this->setLogLevel($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL));
51  if (!$this->isActive()) {
52  $this->resetActivatedComponents();
53  } else {
54  $cache_components = $ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
55  if (is_array($cache_components)) {
56  foreach ($cache_components as $comp => $v) {
57  if ($v) {
58  $this->addActivatedComponent($comp);
59  }
60  }
61  }
62  }
63  }
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 104 of file class.ilGlobalCacheSettings.php.

Referenced by readFromIniFile().

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

◆ setActivatedComponents()

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

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

References $activated_components.

161  {
162  $this->activated_components = $activated_components;
163  }

◆ setActive()

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

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

References $active.

Referenced by readFromIniFile().

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

◆ setLogLevel()

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

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

References $log_level.

Referenced by readFromIniFile().

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

◆ setService()

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

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

References $service.

Referenced by readFromIniFile().

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

◆ writeToIniFile()

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

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

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

70  {
71  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE, $this->isActive() ? '1' : '0');
72  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE, $this->getService());
73  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL, $this->getLogLevel());
74 
75  $ilIniFile->removeGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
76  $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
77  foreach (ilGlobalCache::getAvailableComponents() as $comp) {
78  $ilIniFile->setVariable(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS, $comp, $this->isComponentActivated($comp) ? '1' : '0');
79  }
80  if ($ilIniFile->write()) {
81  ilGlobalCache::log('saved new settings: ' . $this->__toString(), self::LOG_LEVEL_FORCED);
82  }
83  }
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 35 of file class.ilGlobalCacheSettings.php.

Referenced by isActive(), and setActive().

◆ $log_level

ilGlobalCacheSettings::$log_level = self::LOG_LEVEL_NONE
protected

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

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

◆ $service

ilGlobalCacheSettings::$service = ilGlobalCache::TYPE_STATIC
protected

Definition at line 27 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 20 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 21 of file class.ilGlobalCacheSettings.php.

◆ INI_FIELD_LOG_LEVEL

const ilGlobalCacheSettings::INI_FIELD_LOG_LEVEL = 'log_level'

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

◆ INI_HEADER_CACHE

const ilGlobalCacheSettings::INI_HEADER_CACHE = 'cache'

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

◆ INI_HEADER_CACHE_ACTIVATED_COMPONENTS

const ilGlobalCacheSettings::INI_HEADER_CACHE_ACTIVATED_COMPONENTS = 'cache_activated_components'

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

Referenced by HTML_Template_IT\init().

◆ LOG_LEVEL_NONE

const ilGlobalCacheSettings::LOG_LEVEL_NONE = 0

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

◆ LOG_LEVEL_NORMAL

const ilGlobalCacheSettings::LOG_LEVEL_NORMAL = 2

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

Referenced by ilGlobalCache\generateServiceId().

◆ LOG_LEVEL_SHY

const ilGlobalCacheSettings::LOG_LEVEL_SHY = 1

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


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