CacheManager.php in X Autoload 7.4
File
lib/CacheManager/CacheManager.php
View source
<?php
namespace Drupal\xautoload\CacheManager;
use Drupal\xautoload\Util;
class CacheManager {
protected $prefix;
protected $observers = array();
protected function __construct($prefix) {
$this->prefix = $prefix;
}
static function create() {
$prefix = variable_get('xautoload_cache_prefix', NULL);
$manager = new self($prefix);
if (empty($prefix)) {
$manager
->renewCachePrefix();
}
return $manager;
}
function observeCachePrefix($observer) {
$observer
->setCachePrefix($this->prefix);
$this->observers[] = $observer;
}
function renewCachePrefix() {
$this->prefix = Util::randomString();
variable_set('xautoload_cache_prefix', $this->prefix);
foreach ($this->observers as $observer) {
$observer
->setCachePrefix($this->prefix);
}
}
}