mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Use application PHIDs in Macro
Summary: Ref T2715. Move Macro to application PHIDs. Test Plan: Used `conduit.query` to look up macros. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6556
This commit is contained in:
parent
f1cd3bc359
commit
adeefa940f
9 changed files with 56 additions and 32 deletions
|
@ -1214,6 +1214,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMacroMailReceiver' => 'applications/macro/mail/PhabricatorMacroMailReceiver.php',
|
||||
'PhabricatorMacroMemeController' => 'applications/macro/controller/PhabricatorMacroMemeController.php',
|
||||
'PhabricatorMacroMemeDialogController' => 'applications/macro/controller/PhabricatorMacroMemeDialogController.php',
|
||||
'PhabricatorMacroPHIDTypeMacro' => 'applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php',
|
||||
'PhabricatorMacroQuery' => 'applications/macro/query/PhabricatorMacroQuery.php',
|
||||
'PhabricatorMacroReplyHandler' => 'applications/macro/mail/PhabricatorMacroReplyHandler.php',
|
||||
'PhabricatorMacroSearchEngine' => 'applications/macro/query/PhabricatorMacroSearchEngine.php',
|
||||
|
@ -3227,6 +3228,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMacroMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'PhabricatorMacroMemeController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroMemeDialogController' => 'PhabricatorMacroController',
|
||||
'PhabricatorMacroPHIDTypeMacro' => 'PhabricatorPHIDType',
|
||||
'PhabricatorMacroQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorMacroReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'PhabricatorMacroSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorMacroPHIDTypeMacro extends PhabricatorPHIDType {
|
||||
|
||||
const TYPECONST = 'MCRO';
|
||||
|
||||
public function getTypeConstant() {
|
||||
return self::TYPECONST;
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Image Macro');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new PhabricatorFileImageMacro();
|
||||
}
|
||||
|
||||
public function loadObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $phids) {
|
||||
|
||||
return id(new PhabricatorMacroQuery())
|
||||
->setViewer($query->getViewer())
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function loadHandles(
|
||||
PhabricatorHandleQuery $query,
|
||||
array $handles,
|
||||
array $objects) {
|
||||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$macro = $objects[$phid];
|
||||
|
||||
$id = $macro->getID();
|
||||
$name = $macro->getName();
|
||||
|
||||
$handle->setName($name);
|
||||
$handle->setFullName(pht('Image Macro "%s"', $name));
|
||||
$handle->setURI("/macro/view/{$id}/");
|
||||
}
|
||||
}
|
||||
|
||||
public function canLoadNamedObject($name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
|
|||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MCRO);
|
||||
PhabricatorMacroPHIDTypeMacro::TYPECONST);
|
||||
}
|
||||
|
||||
public function isAutomaticallySubscribed($phid) {
|
||||
|
|
|
@ -12,7 +12,7 @@ final class PhabricatorMacroTransaction
|
|||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorPHIDConstants::PHID_TYPE_MCRO;
|
||||
return PhabricatorMacroPHIDTypeMacro::TYPECONST;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
|
|
|
@ -109,7 +109,6 @@ final class PhabricatorObjectHandle
|
|||
|
||||
static $map = array(
|
||||
PhabricatorPHIDConstants::PHID_TYPE_USER => 'User',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'Image Macro',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_PIMG => 'Pholio Image',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_POST => 'Post',
|
||||
|
|
|
@ -18,7 +18,6 @@ final class PhabricatorPHIDConstants {
|
|||
const PHID_TYPE_BLOG = 'BLOG';
|
||||
const PHID_TYPE_ANSW = 'ANSW';
|
||||
const PHID_TYPE_PIMG = 'PIMG';
|
||||
const PHID_TYPE_MCRO = 'MCRO';
|
||||
const PHID_TYPE_CONP = 'CONP';
|
||||
const PHID_TYPE_PVAR = 'PVAR';
|
||||
const PHID_TYPE_ACNT = 'ACNT';
|
||||
|
|
|
@ -89,7 +89,7 @@ final class PhabricatorObjectHandleData {
|
|||
->execute();
|
||||
$xactions += mpull($results, null, 'getPHID');
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MCRO:
|
||||
case PhabricatorMacroPHIDTypeMacro::TYPECONST:
|
||||
$results = id(new PhabricatorMacroTransactionQuery())
|
||||
->setViewer($this->viewer)
|
||||
->withPHIDs($subtype_phids)
|
||||
|
@ -100,13 +100,6 @@ final class PhabricatorObjectHandleData {
|
|||
}
|
||||
return mpull($xactions, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MCRO:
|
||||
$macros = id(new PhabricatorMacroQuery())
|
||||
->setViewer($this->viewer)
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
return mpull($macros, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_BLOG:
|
||||
$blogs = id(new PhameBlogQuery())
|
||||
->withPHIDs($phids)
|
||||
|
@ -341,24 +334,6 @@ final class PhabricatorObjectHandleData {
|
|||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MCRO:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($objects[$phid])) {
|
||||
$handle->setName('Unknown Macro');
|
||||
} else {
|
||||
$macro = $objects[$phid];
|
||||
$handle->setName($macro->getName());
|
||||
$handle->setFullName('Image Macro "'.$macro->getName().'"');
|
||||
$handle->setURI('/macro/view/'.$macro->getID().'/');
|
||||
$handle->setComplete(true);
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_PVAR:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
|
|
|
@ -159,7 +159,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'PhameBlog',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_POST => 'PhamePost',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_ANSW => 'PonderAnswer',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'PhabricatorFileImageMacro',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_CONP => 'ConpherenceThread',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_ACNT => 'PhortuneAccount',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_PRCH => 'PhortunePurchase',
|
||||
|
|
|
@ -237,7 +237,7 @@ final class PHUIFeedStoryView extends AphrontView {
|
|||
case PholioPHIDTypeMock::TYPECONST:
|
||||
$this->setAppIcon("pholio-dark");
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MCRO:
|
||||
case PhabricatorMacroPHIDTypeMacro::TYPECONST:
|
||||
$this->setAppIcon("macro-dark");
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue