本文整理匯總了PHP中PhabricatorHash::digestToLength方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhabricatorHash::digestToLength方法的具體用法?PHP PhabricatorHash::digestToLength怎麽用?PHP PhabricatorHash::digestToLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhabricatorHash
的用法示例。
在下文中一共展示了PhabricatorHash::digestToLength方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getBuiltinFileKey
public function getBuiltinFileKey()
{
$name = $this->getName();
$desc = "disk(name={$name})";
$hash = PhabricatorHash::digestToLength($desc, 40);
return "builtin:{$hash}";
}
示例2: getBuiltinFileKey
public function getBuiltinFileKey()
{
$icon = $this->getIcon();
$color = $this->getColor();
$desc = "compose(icon={$icon}, color={$color})";
$hash = PhabricatorHash::digestToLength($desc, 40);
return "builtin:{$hash}";
}
示例3: newLock
public static function newLock($name)
{
$namespace = PhabricatorLiskDAO::getStorageNamespace();
$namespace = PhabricatorHash::digestToLength($namespace, 20);
$full_name = 'ph:' . $namespace . ':' . $name;
$length_limit = 64;
if (strlen($full_name) > $length_limit) {
throw new Exception(pht('Lock name "%s" is too long (full lock name is "%s"). The ' . 'full lock name must not be longer than %s bytes.', $name, $full_name, new PhutilNumber($length_limit)));
}
$lock = self::getLock($full_name);
if (!$lock) {
$lock = new PhabricatorGlobalLock($full_name);
self::registerLock($lock);
}
return $lock;
}
示例4: importFromSource
public final function importFromSource()
{
if (!$this->shouldPullDataFromSource()) {
return false;
}
$source = $this->getSource();
$key = $this->getCursorKey();
$parts = array('nsc', $source->getID(), PhabricatorHash::digestToLength($key, 20));
$lock_name = implode('.', $parts);
$lock = PhabricatorGlobalLock::newLock($lock_name);
$lock->lock(1);
try {
$more_data = $this->pullDataFromSource();
} catch (Exception $ex) {
$lock->unlock();
throw $ex;
}
$lock->unlock();
return $more_data;
}
示例5: getFieldsForObject
public function getFieldsForObject($object)
{
$field_list = PhabricatorCustomField::getObjectFields($object, PhabricatorCustomField::ROLE_HERALD);
$field_list->setViewer(PhabricatorUser::getOmnipotentUser());
$field_list->readFieldsFromStorage($object);
$prefix = 'herald.custom/';
$limit = self::getFieldConstantByteLimit();
$map = array();
foreach ($field_list->getFields() as $field) {
$key = $field->getFieldKey();
// NOTE: This use of digestToLength() isn't preferred (you should
// normally digest a key unconditionally, so that it isn't possible to
// arrange a collision) but preserves backward compatibility.
$full_key = $prefix . $key;
if (strlen($full_key) > $limit) {
$full_key = PhabricatorHash::digestToLength($full_key, $limit);
}
$map[$full_key] = id(new PhabricatorCustomFieldHeraldField())->setCustomField($field);
}
return $map;
}
示例6: getCacheKey
protected function getCacheKey($path)
{
return 'celerity:' . PhabricatorHash::digestToLength($path, 64);
}