class CacheManager in X Autoload 7.4
Same name and namespace in other branches
- 7.5 src/CacheManager/CacheManager.php \Drupal\xautoload\CacheManager\CacheManager
Hierarchy
- class \Drupal\xautoload\CacheManager\CacheManager
Expanded class hierarchy of CacheManager
3 files declare their use of CacheManager
- AbstractCachedClassLoader.php in lib/
ClassLoader/ AbstractCachedClassLoader.php - ServiceContainerInterface.php in lib/
DIC/ ServiceContainerInterface.php - ServiceFactory.php in lib/
DIC/ ServiceFactory.php
File
- lib/
CacheManager/ CacheManager.php, line 7
Namespace
Drupal\xautoload\CacheManagerView source
class CacheManager {
/**
* @var string
*/
protected $prefix;
/**
* @var CacheManagerObserverInterface[]
*/
protected $observers = array();
/**
* @param $prefix
*/
protected function __construct($prefix) {
$this->prefix = $prefix;
}
/**
* This method has side effects, so it is not the constructor.
*
* @return CacheManager
*/
static function create() {
$prefix = variable_get('xautoload_cache_prefix', NULL);
$manager = new self($prefix);
if (empty($prefix)) {
$manager
->renewCachePrefix();
}
return $manager;
}
/**
* @param CacheManagerObserverInterface $observer
*/
function observeCachePrefix($observer) {
$observer
->setCachePrefix($this->prefix);
$this->observers[] = $observer;
}
/**
* Renew the cache prefix, save it, and notify all observers.
*/
function renewCachePrefix() {
$this->prefix = Util::randomString();
variable_set('xautoload_cache_prefix', $this->prefix);
foreach ($this->observers as $observer) {
$observer
->setCachePrefix($this->prefix);
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheManager:: |
protected | property | ||
CacheManager:: |
protected | property | ||
CacheManager:: |
static | function | This method has side effects, so it is not the constructor. | |
CacheManager:: |
function | |||
CacheManager:: |
function | Renew the cache prefix, save it, and notify all observers. | ||
CacheManager:: |
protected | function |