mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 21:10:56 +01:00
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
This commit is contained in:
parent
adeefa940f
commit
3160bb0932
7 changed files with 53 additions and 31 deletions
|
@ -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' =>
|
||||
|
|
|
@ -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',
|
||||
);
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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();
|
||||
|
|
49
src/applications/phlux/phid/PhluxPHIDTypeVariable.php
Normal file
49
src/applications/phlux/phid/PhluxPHIDTypeVariable.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
final class PhluxPHIDTypeVariable extends PhabricatorPHIDType {
|
||||
|
||||
const TYPECONST = 'PVAR';
|
||||
|
||||
public function getTypeConstant() {
|
||||
return self::TYPECONST;
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Variable');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new PhluxVariable();
|
||||
}
|
||||
|
||||
public function loadObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $phids) {
|
||||
|
||||
return id(new PhluxVariableQuery())
|
||||
->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ final class PhluxTransaction extends PhabricatorApplicationTransaction {
|
|||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorPHIDConstants::PHID_TYPE_PVAR;
|
||||
return PhluxPHIDTypeVariable::TYPECONST;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
|
|
|
@ -18,8 +18,7 @@ final class PhluxVariable extends PhluxDAO
|
|||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
PhabricatorPHIDConstants::PHID_TYPE_PVAR);
|
||||
return PhabricatorPHID::generateNewPHID(PhluxPHIDTypeVariable::TYPECONST);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue