本文整理汇总了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);
}