From 3160bb0932dfbfa41ca8a324e2a66f20d864ed0c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 24 Jul 2013 14:06:50 -0700 Subject: [PATCH] Use application PHIDs in Phlux Summary: Ref T2715. PVAR -> app phids Test Plan: Used `conduit.query` to load one. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6557 --- src/__phutil_library_map__.php | 2 + .../phid/PhabricatorObjectHandle.php | 1 - .../phid/PhabricatorPHIDConstants.php | 1 - .../handle/PhabricatorObjectHandleData.php | 26 ---------- .../phlux/phid/PhluxPHIDTypeVariable.php | 49 +++++++++++++++++++ .../phlux/storage/PhluxTransaction.php | 2 +- .../phlux/storage/PhluxVariable.php | 3 +- 7 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 src/applications/phlux/phid/PhluxPHIDTypeVariable.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a6522345cc..f55ae3d51f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1728,6 +1728,7 @@ phutil_register_library_map(array( 'PhluxDAO' => 'applications/phlux/storage/PhluxDAO.php', 'PhluxEditController' => 'applications/phlux/controller/PhluxEditController.php', 'PhluxListController' => 'applications/phlux/controller/PhluxListController.php', + 'PhluxPHIDTypeVariable' => 'applications/phlux/phid/PhluxPHIDTypeVariable.php', 'PhluxTransaction' => 'applications/phlux/storage/PhluxTransaction.php', 'PhluxTransactionQuery' => 'applications/phlux/query/PhluxTransactionQuery.php', 'PhluxVariable' => 'applications/phlux/storage/PhluxVariable.php', @@ -3769,6 +3770,7 @@ phutil_register_library_map(array( 'PhluxDAO' => 'PhabricatorLiskDAO', 'PhluxEditController' => 'PhluxController', 'PhluxListController' => 'PhluxController', + 'PhluxPHIDTypeVariable' => 'PhabricatorPHIDType', 'PhluxTransaction' => 'PhabricatorApplicationTransaction', 'PhluxTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhluxVariable' => diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php index de292cfd96..6b3fa3b544 100644 --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -112,7 +112,6 @@ final class PhabricatorObjectHandle PhabricatorPHIDConstants::PHID_TYPE_PIMG => 'Pholio Image', PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog', PhabricatorPHIDConstants::PHID_TYPE_POST => 'Post', - PhabricatorPHIDConstants::PHID_TYPE_PVAR => 'Variable', PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'Legalpad Document', ); diff --git a/src/applications/phid/PhabricatorPHIDConstants.php b/src/applications/phid/PhabricatorPHIDConstants.php index 83c72e3a51..f0ec72187f 100644 --- a/src/applications/phid/PhabricatorPHIDConstants.php +++ b/src/applications/phid/PhabricatorPHIDConstants.php @@ -19,7 +19,6 @@ final class PhabricatorPHIDConstants { const PHID_TYPE_ANSW = 'ANSW'; const PHID_TYPE_PIMG = 'PIMG'; const PHID_TYPE_CONP = 'CONP'; - const PHID_TYPE_PVAR = 'PVAR'; const PHID_TYPE_ACNT = 'ACNT'; const PHID_TYPE_PDCT = 'PDCT'; const PHID_TYPE_PRCH = 'PRCH'; diff --git a/src/applications/phid/handle/PhabricatorObjectHandleData.php b/src/applications/phid/handle/PhabricatorObjectHandleData.php index 66987464f9..10d85f3c5d 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/PhabricatorObjectHandleData.php @@ -114,13 +114,6 @@ final class PhabricatorObjectHandleData { ->execute(); return mpull($posts, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_PVAR: - $vars = id(new PhluxVariableQuery()) - ->withPHIDs($phids) - ->setViewer($this->viewer) - ->execute(); - return mpull($vars, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_XUSR: $xusr_dao = new PhabricatorExternalAccount(); $xusrs = $xusr_dao->loadAllWhere( @@ -334,25 +327,6 @@ final class PhabricatorObjectHandleData { } break; - case PhabricatorPHIDConstants::PHID_TYPE_PVAR: - foreach ($phids as $phid) { - $handle = new PhabricatorObjectHandle(); - $handle->setPHID($phid); - $handle->setType($type); - if (empty($objects[$phid])) { - $handle->setName('Unknown Variable'); - } else { - $var = $objects[$phid]; - $key = $var->getVariableKey(); - $handle->setName($key); - $handle->setFullName('Phlux Variable "'.$key.'"'); - $handle->setURI('/phlux/view/'.$key.'/'); - $handle->setComplete(true); - } - $handles[$phid] = $handle; - } - break; - case PhabricatorPHIDConstants::PHID_TYPE_XUSR: foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); diff --git a/src/applications/phlux/phid/PhluxPHIDTypeVariable.php b/src/applications/phlux/phid/PhluxPHIDTypeVariable.php new file mode 100644 index 0000000000..cfb479c329 --- /dev/null +++ b/src/applications/phlux/phid/PhluxPHIDTypeVariable.php @@ -0,0 +1,49 @@ +setViewer($query->getViewer()) + ->withPHIDs($phids) + ->execute(); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $variable = $objects[$phid]; + + $key = $variable->getVariableKey(); + + $handle->setName($key); + $handle->setFullName(pht('Variable "%s"', $key)); + $handle->setURI("/phlux/view/{$key}/"); + } + } + + public function canLoadNamedObject($name) { + return false; + } + +} diff --git a/src/applications/phlux/storage/PhluxTransaction.php b/src/applications/phlux/storage/PhluxTransaction.php index 4193583cb1..b2712baf50 100644 --- a/src/applications/phlux/storage/PhluxTransaction.php +++ b/src/applications/phlux/storage/PhluxTransaction.php @@ -10,7 +10,7 @@ final class PhluxTransaction extends PhabricatorApplicationTransaction { } public function getApplicationTransactionType() { - return PhabricatorPHIDConstants::PHID_TYPE_PVAR; + return PhluxPHIDTypeVariable::TYPECONST; } public function getApplicationTransactionCommentObject() { diff --git a/src/applications/phlux/storage/PhluxVariable.php b/src/applications/phlux/storage/PhluxVariable.php index c351578b4f..f279700224 100644 --- a/src/applications/phlux/storage/PhluxVariable.php +++ b/src/applications/phlux/storage/PhluxVariable.php @@ -18,8 +18,7 @@ final class PhluxVariable extends PhluxDAO } public function generatePHID() { - return PhabricatorPHID::generateNewPHID( - PhabricatorPHIDConstants::PHID_TYPE_PVAR); + return PhabricatorPHID::generateNewPHID(PhluxPHIDTypeVariable::TYPECONST); }