class CacheManager in X Autoload 7.5
Same name and namespace in other branches
- 7.4 lib/CacheManager/CacheManager.php \Drupal\xautoload\CacheManager\CacheManager
Hierarchy
- class \Drupal\xautoload\CacheManager\CacheManager
Expanded class hierarchy of CacheManager
5 files declare their use of CacheManager
- AbstractCachedClassLoader.php in src/
ClassLoader/ AbstractCachedClassLoader.php - AbstractQueuedCachedClassLoader.php in src/
ClassLoader/ AbstractQueuedCachedClassLoader.php - DbCacheClassLoader.php in src/
ClassLoader/ DbCacheClassLoader.php - ServiceContainerInterface.php in src/
DIC/ ServiceContainerInterface.php - ServiceFactory.php in src/
DIC/ ServiceFactory.php
File
- src/
CacheManager/ CacheManager.php, line 8
Namespace
Drupal\xautoload\CacheManagerView source
class CacheManager {
/**
* @var string
*/
protected $prefix;
/**
* @var \Drupal\xautoload\DrupalSystem\DrupalSystemInterface
*/
protected $system;
/**
* @var CacheManagerObserverInterface[]
*/
protected $observers = array();
/**
* @param string $prefix
* @param \Drupal\xautoload\DrupalSystem\DrupalSystemInterface $system
*/
protected function __construct($prefix, DrupalSystemInterface $system) {
$this->prefix = $prefix;
$this->system = $system;
}
/**
* This method has side effects, so it is not the constructor.
*
* @param \Drupal\xautoload\DrupalSystem\DrupalSystemInterface $system
*
* @return CacheManager
*/
static function create(DrupalSystemInterface $system) {
$prefix = $system
->variableGet(XAUTOLOAD_VARNAME_CACHE_PREFIX, NULL);
$manager = new self($prefix, $system);
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();
$this->system
->variableSet(XAUTOLOAD_VARNAME_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:: |
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 |