Page MenuHomec4science

PhabricatorUserCacheType.php
No OneTemporary

File Metadata

Created
Mon, Jul 15, 02:07

PhabricatorUserCacheType.php

<?php
abstract class PhabricatorUserCacheType extends Phobject {
final public function getViewer() {
return PhabricatorUser::getOmnipotentUser();
}
public function getAutoloadKeys() {
return array();
}
public function canManageKey($key) {
return false;
}
public function getDefaultValue() {
return array();
}
public function getValueFromStorage($value) {
return phutil_json_decode($value);
}
public function getValueForStorage($value) {
return phutil_json_encode($value);
}
public function newValueForUsers($key, array $users) {
return array();
}
final public function getUserCacheType() {
return $this->getPhobjectClassConstant('CACHETYPE');
}
public static function getAllCacheTypes() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getUserCacheType')
->execute();
}
public static function getCacheTypeForKey($key) {
$all = self::getAllCacheTypes();
foreach ($all as $type) {
if ($type->canManageKey($key)) {
return $type;
}
}
return null;
}
public static function requireCacheTypeForKey($key) {
$type = self::getCacheTypeForKey($key);
if (!$type) {
throw new Exception(
pht(
'Failed to load UserCacheType to manage key "%s". This cache type '.
'is required.',
$key));
}
return $type;
}
}

Event Timeline