本文整理汇总了PHP中PhabricatorHash::digestForIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorHash::digestForIndex方法的具体用法?PHP PhabricatorHash::digestForIndex怎么用?PHP PhabricatorHash::digestForIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorHash
的用法示例。
在下文中一共展示了PhabricatorHash::digestForIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildWhereClauseParts
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn)
{
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf($conn, 'service.id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn, 'service.phid IN (%Ls)', $this->phids);
}
if ($this->names !== null) {
$hashes = array();
foreach ($this->names as $name) {
$hashes[] = PhabricatorHash::digestForIndex($name);
}
$where[] = qsprintf($conn, 'service.nameIndex IN (%Ls)', $hashes);
}
if ($this->serviceTypes !== null) {
$where[] = qsprintf($conn, 'service.serviceType IN (%Ls)', $this->serviceTypes);
}
if ($this->devicePHIDs !== null) {
$where[] = qsprintf($conn, 'binding.devicePHID IN (%Ls)', $this->devicePHIDs);
}
if ($this->namePrefix !== null) {
$where[] = qsprintf($conn, 'service.name LIKE %>', $this->namePrefix);
}
if ($this->nameSuffix !== null) {
$where[] = qsprintf($conn, 'service.name LIKE %<', $this->nameSuffix);
}
return $where;
}
示例2: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn_r, 'phid IN (%Ls)', $this->phids);
}
if ($this->names !== null) {
$hashes = array();
foreach ($this->names as $name) {
$hashes[] = PhabricatorHash::digestForIndex($name);
}
$where[] = qsprintf($conn_r, 'nameIndex IN (%Ls)', $hashes);
}
if ($this->namePrefix !== null) {
$where[] = qsprintf($conn_r, 'name LIKE %>', $this->namePrefix);
}
if ($this->nameSuffix !== null) {
$where[] = qsprintf($conn_r, 'name LIKE %<', $this->nameSuffix);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例3: buildWhereClauseParts
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn)
{
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn, 'phid IN (%Ls)', $this->phids);
}
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf($conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs);
}
if ($this->refTypes !== null) {
$where[] = qsprintf($conn, 'refType IN (%Ls)', $this->refTypes);
}
if ($this->refNames !== null) {
$name_hashes = array();
foreach ($this->refNames as $name) {
$name_hashes[] = PhabricatorHash::digestForIndex($name);
}
$where[] = qsprintf($conn, 'refNameHash IN (%Ls)', $name_hashes);
}
if (strlen($this->datasourceQuery)) {
$where[] = qsprintf($conn, 'refNameRaw LIKE %>', $this->datasourceQuery);
}
return $where;
}
示例4: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf($conn_r, 'phid IN (%Ls)', $this->phids);
}
if ($this->emailAddresses !== null) {
$where[] = qsprintf($conn_r, 'emailAddress IN (%Ls)', $this->emailAddresses);
}
if ($this->verificationCodes !== null) {
$hashes = array();
foreach ($this->verificationCodes as $code) {
$hashes[] = PhabricatorHash::digestForIndex($code);
}
$where[] = qsprintf($conn_r, 'verificationHash IN (%Ls)', $hashes);
}
if ($this->authorPHIDs !== null) {
$where[] = qsprintf($conn_r, 'authorPHID IN (%Ls)', $this->authorPHIDs);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
示例5: getArtifactIndex
public static function getArtifactIndex(HarbormasterBuildTarget $target, $artifact_key)
{
$build = $target->getBuild();
$parts = array($build->getPHID(), $target->getBuildGeneration(), $artifact_key);
$parts = implode("", $parts);
return PhabricatorHash::digestForIndex($parts);
}
示例6: setRefName
public function setRefName($ref_raw)
{
$this->setRefNameRaw($ref_raw);
$this->setRefNameHash(PhabricatorHash::digestForIndex($ref_raw));
$this->setRefNameEncoding($this->detectEncodingForStorage($ref_raw));
return $this;
}
示例7: save
public function save()
{
if (!$this->getVerificationHash()) {
$hash = PhabricatorHash::digestForIndex($this->getVerificationCode());
$this->setVerificationHash($hash);
}
return parent::save();
}
示例8: getIndexVersion
public function getIndexVersion($object)
{
$ngrams = $object->newNgrams();
$map = mpull($ngrams, 'getValue', 'getNgramKey');
ksort($map);
$serialized = serialize($map);
return PhabricatorHash::digestForIndex($serialized);
}
示例9: save
public function save()
{
AlmanacNames::validateName($this->getName());
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName());
if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20);
}
return parent::save();
}
示例10: doWork
protected function doWork()
{
$resource_phid = $this->getTaskDataValue('resourcePHID');
$hash = PhabricatorHash::digestForIndex($resource_phid);
$lock_key = 'drydock.resource:' . $hash;
$lock = PhabricatorGlobalLock::newLock($lock_key)->lock(1);
$resource = $this->loadResource($resource_phid);
$this->updateResource($resource);
$lock->unlock();
}
示例11: clearCacheForAllUsers
public static function clearCacheForAllUsers($key)
{
if (PhabricatorEnv::isReadOnly()) {
return;
}
$table = new self();
$conn_w = $table->establishConnection('w');
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
queryfx($conn_w, 'DELETE FROM %T WHERE cacheIndex = %s', $table->getTableName(), PhabricatorHash::digestForIndex($key));
unset($unguarded);
}
示例12: applyApplicationTransactionExternalEffects
public function applyApplicationTransactionExternalEffects(PhabricatorApplicationTransaction $xaction)
{
$object = $this->getObject();
$phid = $object->getPHID();
$key = $this->getFieldKey();
$property = id(new AlmanacPropertyQuery())->setViewer($this->getViewer())->withObjectPHIDs(array($phid))->withNames(array($key))->executeOne();
if (!$property) {
$property = id(new AlmanacProperty())->setObjectPHID($phid)->setFieldIndex(PhabricatorHash::digestForIndex($key))->setFieldName($key);
}
$property->setFieldValue($xaction->getNewValue())->save();
}
示例13: save
public function save()
{
if ($this->getEngineClassName() === null) {
throw new Exception(pht('Engine class is null.'));
}
// Instantiate the engine to make sure it's valid.
$this->newEngine();
$serial = $this->getEngineClassName() . serialize($this->parameters);
$this->queryKey = PhabricatorHash::digestForIndex($serial);
return parent::save();
}
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$show_prototypes = PhabricatorEnv::getEnvConfig('phabricator.show-prototypes');
if (!$show_prototypes) {
throw new Exception(pht('Show prototypes is disabled.
Set `phabricator.show-prototypes` to `true` to use the image proxy'));
}
$viewer = $request->getViewer();
$img_uri = $request->getStr('uri');
// Validate the URI before doing anything
PhabricatorEnv::requireValidRemoteURIForLink($img_uri);
$uri = new PhutilURI($img_uri);
$proto = $uri->getProtocol();
if (!in_array($proto, array('http', 'https'))) {
throw new Exception(pht('The provided image URI must be either http or https'));
}
// Check if we already have the specified image URI downloaded
$cached_request = id(new PhabricatorFileExternalRequest())->loadOneWhere('uriIndex = %s', PhabricatorHash::digestForIndex($img_uri));
if ($cached_request) {
return $this->getExternalResponse($cached_request);
}
$ttl = PhabricatorTime::getNow() + phutil_units('7 days in seconds');
$external_request = id(new PhabricatorFileExternalRequest())->setURI($img_uri)->setTTL($ttl);
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
// Cache missed so we'll need to validate and download the image
try {
// Rate limit outbound fetches to make this mechanism less useful for
// scanning networks and ports.
PhabricatorSystemActionEngine::willTakeAction(array($viewer->getPHID()), new PhabricatorFilesOutboundRequestAction(), 1);
$file = PhabricatorFile::newFromFileDownload($uri, array('viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'canCDN' => true));
if (!$file->isViewableImage()) {
$mime_type = $file->getMimeType();
$engine = new PhabricatorDestructionEngine();
$engine->destroyObject($file);
$file = null;
throw new Exception(pht('The URI "%s" does not correspond to a valid image file, got ' . 'a file with MIME type "%s". You must specify the URI of a ' . 'valid image file.', $uri, $mime_type));
} else {
$file->save();
}
$external_request->setIsSuccessful(true)->setFilePHID($file->getPHID())->save();
unset($unguarded);
return $this->getExternalResponse($external_request);
} catch (HTTPFutureHTTPResponseStatus $status) {
$external_request->setIsSuccessful(false)->setResponseMessage($status->getMessage())->save();
return $this->getExternalResponse($external_request);
} catch (Exception $ex) {
// Not actually saving the request in this case
$external_request->setResponseMessage($ex->getMessage());
return $this->getExternalResponse($external_request);
}
}
示例15: setHeaders
public function setHeaders(array $headers)
{
// Normalize headers to lowercase.
$normalized = array();
foreach ($headers as $name => $value) {
$name = $this->normalizeMailHeaderName($name);
if ($name == 'message-id') {
$this->setMessageIDHash(PhabricatorHash::digestForIndex($value));
}
$normalized[$name] = $value;
}
$this->headers = $normalized;
return $this;
}