1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Add PHIDType for HeraldTransaction

Test Plan: Paste a HLXS phid to the quick-search box, get transaction page.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D15028
This commit is contained in:
Aviv Eyal 2016-01-15 16:40:48 +00:00 committed by avivey
parent 98d2370672
commit aadc1b7bf0
4 changed files with 59 additions and 1 deletions

View file

@ -1201,6 +1201,7 @@ phutil_register_library_map(array(
'HeraldTranscriptDestructionEngineExtension' => 'applications/herald/engineextension/HeraldTranscriptDestructionEngineExtension.php', 'HeraldTranscriptDestructionEngineExtension' => 'applications/herald/engineextension/HeraldTranscriptDestructionEngineExtension.php',
'HeraldTranscriptGarbageCollector' => 'applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php', 'HeraldTranscriptGarbageCollector' => 'applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php',
'HeraldTranscriptListController' => 'applications/herald/controller/HeraldTranscriptListController.php', 'HeraldTranscriptListController' => 'applications/herald/controller/HeraldTranscriptListController.php',
'HeraldTranscriptPHIDType' => 'applications/herald/phid/HeraldTranscriptPHIDType.php',
'HeraldTranscriptQuery' => 'applications/herald/query/HeraldTranscriptQuery.php', 'HeraldTranscriptQuery' => 'applications/herald/query/HeraldTranscriptQuery.php',
'HeraldTranscriptSearchEngine' => 'applications/herald/query/HeraldTranscriptSearchEngine.php', 'HeraldTranscriptSearchEngine' => 'applications/herald/query/HeraldTranscriptSearchEngine.php',
'HeraldTranscriptTestCase' => 'applications/herald/storage/__tests__/HeraldTranscriptTestCase.php', 'HeraldTranscriptTestCase' => 'applications/herald/storage/__tests__/HeraldTranscriptTestCase.php',
@ -5297,6 +5298,7 @@ phutil_register_library_map(array(
'HeraldTranscriptDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension', 'HeraldTranscriptDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension',
'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector', 'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector',
'HeraldTranscriptListController' => 'HeraldController', 'HeraldTranscriptListController' => 'HeraldController',
'HeraldTranscriptPHIDType' => 'PhabricatorPHIDType',
'HeraldTranscriptQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HeraldTranscriptQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'HeraldTranscriptSearchEngine' => 'PhabricatorApplicationSearchEngine', 'HeraldTranscriptSearchEngine' => 'PhabricatorApplicationSearchEngine',
'HeraldTranscriptTestCase' => 'PhabricatorTestCase', 'HeraldTranscriptTestCase' => 'PhabricatorTestCase',

View file

@ -0,0 +1,42 @@
<?php
final class HeraldTranscriptPHIDType extends PhabricatorPHIDType {
const TYPECONST = 'HLXS';
public function getTypeName() {
return pht('Herald Transcript');
}
public function newObject() {
return new HeraldTranscript();
}
public function getPHIDTypeApplicationClass() {
return 'PhabricatorHeraldApplication';
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new HeraldTranscriptQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$xscript = $objects[$phid];
$id = $xscript->getID();
$handle->setName(pht('Transcript %s', $id));
$handle->setURI("/herald/transcript/${id}/");
}
}
}

View file

@ -4,6 +4,7 @@ final class HeraldTranscriptQuery
extends PhabricatorCursorPagedPolicyAwareQuery { extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids; private $ids;
private $phids;
private $objectPHIDs; private $objectPHIDs;
private $needPartialRecords; private $needPartialRecords;
@ -12,6 +13,11 @@ final class HeraldTranscriptQuery
return $this; return $this;
} }
public function withPHIDs(array $phids) {
$this->phids = $phids;
return $this;
}
public function withObjectPHIDs(array $phids) { public function withObjectPHIDs(array $phids) {
$this->objectPHIDs = $phids; $this->objectPHIDs = $phids;
return $this; return $this;
@ -95,6 +101,13 @@ final class HeraldTranscriptQuery
$this->ids); $this->ids);
} }
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
'phid IN (%Ls)',
$this->phids);
}
if ($this->objectPHIDs) { if ($this->objectPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn_r,

View file

@ -190,7 +190,8 @@ final class HeraldTranscript extends HeraldDAO
} }
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID('HLXS'); return PhabricatorPHID::generateNewPHID(
HeraldTranscriptPHIDType::TYPECONST);
} }
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */