From aadc1b7bf024aadd0f3619a84dda76d2e1e640b4 Mon Sep 17 00:00:00 2001 From: Aviv Eyal Date: Fri, 15 Jan 2016 16:40:48 +0000 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 2 + .../herald/phid/HeraldTranscriptPHIDType.php | 42 +++++++++++++++++++ .../herald/query/HeraldTranscriptQuery.php | 13 ++++++ .../storage/transcript/HeraldTranscript.php | 3 +- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/applications/herald/phid/HeraldTranscriptPHIDType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index beaa00bcd6..3f8d654711 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1201,6 +1201,7 @@ phutil_register_library_map(array( 'HeraldTranscriptDestructionEngineExtension' => 'applications/herald/engineextension/HeraldTranscriptDestructionEngineExtension.php', 'HeraldTranscriptGarbageCollector' => 'applications/herald/garbagecollector/HeraldTranscriptGarbageCollector.php', 'HeraldTranscriptListController' => 'applications/herald/controller/HeraldTranscriptListController.php', + 'HeraldTranscriptPHIDType' => 'applications/herald/phid/HeraldTranscriptPHIDType.php', 'HeraldTranscriptQuery' => 'applications/herald/query/HeraldTranscriptQuery.php', 'HeraldTranscriptSearchEngine' => 'applications/herald/query/HeraldTranscriptSearchEngine.php', 'HeraldTranscriptTestCase' => 'applications/herald/storage/__tests__/HeraldTranscriptTestCase.php', @@ -5297,6 +5298,7 @@ phutil_register_library_map(array( 'HeraldTranscriptDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension', 'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector', 'HeraldTranscriptListController' => 'HeraldController', + 'HeraldTranscriptPHIDType' => 'PhabricatorPHIDType', 'HeraldTranscriptQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HeraldTranscriptSearchEngine' => 'PhabricatorApplicationSearchEngine', 'HeraldTranscriptTestCase' => 'PhabricatorTestCase', diff --git a/src/applications/herald/phid/HeraldTranscriptPHIDType.php b/src/applications/herald/phid/HeraldTranscriptPHIDType.php new file mode 100644 index 0000000000..8ba3a0254c --- /dev/null +++ b/src/applications/herald/phid/HeraldTranscriptPHIDType.php @@ -0,0 +1,42 @@ +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}/"); + } + } + +} diff --git a/src/applications/herald/query/HeraldTranscriptQuery.php b/src/applications/herald/query/HeraldTranscriptQuery.php index d679009c4e..7d0fdfc59e 100644 --- a/src/applications/herald/query/HeraldTranscriptQuery.php +++ b/src/applications/herald/query/HeraldTranscriptQuery.php @@ -4,6 +4,7 @@ final class HeraldTranscriptQuery extends PhabricatorCursorPagedPolicyAwareQuery { private $ids; + private $phids; private $objectPHIDs; private $needPartialRecords; @@ -12,6 +13,11 @@ final class HeraldTranscriptQuery return $this; } + public function withPHIDs(array $phids) { + $this->phids = $phids; + return $this; + } + public function withObjectPHIDs(array $phids) { $this->objectPHIDs = $phids; return $this; @@ -95,6 +101,13 @@ final class HeraldTranscriptQuery $this->ids); } + if ($this->phids) { + $where[] = qsprintf( + $conn_r, + 'phid IN (%Ls)', + $this->phids); + } + if ($this->objectPHIDs) { $where[] = qsprintf( $conn_r, diff --git a/src/applications/herald/storage/transcript/HeraldTranscript.php b/src/applications/herald/storage/transcript/HeraldTranscript.php index 8b458c93ff..474eb10b53 100644 --- a/src/applications/herald/storage/transcript/HeraldTranscript.php +++ b/src/applications/herald/storage/transcript/HeraldTranscript.php @@ -190,7 +190,8 @@ final class HeraldTranscript extends HeraldDAO } public function generatePHID() { - return PhabricatorPHID::generateNewPHID('HLXS'); + return PhabricatorPHID::generateNewPHID( + HeraldTranscriptPHIDType::TYPECONST); } /* -( PhabricatorPolicyInterface )----------------------------------------- */