1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +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:
epriestley 2013-07-24 14:06:10 -07:00
parent f1cd3bc359
commit adeefa940f
9 changed files with 56 additions and 32 deletions

View file

@ -1214,6 +1214,7 @@ phutil_register_library_map(array(
'PhabricatorMacroMailReceiver' => 'applications/macro/mail/PhabricatorMacroMailReceiver.php', 'PhabricatorMacroMailReceiver' => 'applications/macro/mail/PhabricatorMacroMailReceiver.php',
'PhabricatorMacroMemeController' => 'applications/macro/controller/PhabricatorMacroMemeController.php', 'PhabricatorMacroMemeController' => 'applications/macro/controller/PhabricatorMacroMemeController.php',
'PhabricatorMacroMemeDialogController' => 'applications/macro/controller/PhabricatorMacroMemeDialogController.php', 'PhabricatorMacroMemeDialogController' => 'applications/macro/controller/PhabricatorMacroMemeDialogController.php',
'PhabricatorMacroPHIDTypeMacro' => 'applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php',
'PhabricatorMacroQuery' => 'applications/macro/query/PhabricatorMacroQuery.php', 'PhabricatorMacroQuery' => 'applications/macro/query/PhabricatorMacroQuery.php',
'PhabricatorMacroReplyHandler' => 'applications/macro/mail/PhabricatorMacroReplyHandler.php', 'PhabricatorMacroReplyHandler' => 'applications/macro/mail/PhabricatorMacroReplyHandler.php',
'PhabricatorMacroSearchEngine' => 'applications/macro/query/PhabricatorMacroSearchEngine.php', 'PhabricatorMacroSearchEngine' => 'applications/macro/query/PhabricatorMacroSearchEngine.php',
@ -3227,6 +3228,7 @@ phutil_register_library_map(array(
'PhabricatorMacroMailReceiver' => 'PhabricatorObjectMailReceiver', 'PhabricatorMacroMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhabricatorMacroMemeController' => 'PhabricatorMacroController', 'PhabricatorMacroMemeController' => 'PhabricatorMacroController',
'PhabricatorMacroMemeDialogController' => 'PhabricatorMacroController', 'PhabricatorMacroMemeDialogController' => 'PhabricatorMacroController',
'PhabricatorMacroPHIDTypeMacro' => 'PhabricatorPHIDType',
'PhabricatorMacroQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorMacroQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorMacroReplyHandler' => 'PhabricatorMailReplyHandler', 'PhabricatorMacroReplyHandler' => 'PhabricatorMailReplyHandler',
'PhabricatorMacroSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorMacroSearchEngine' => 'PhabricatorApplicationSearchEngine',

View file

@ -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;
}
}

View file

@ -35,7 +35,7 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID( return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_MCRO); PhabricatorMacroPHIDTypeMacro::TYPECONST);
} }
public function isAutomaticallySubscribed($phid) { public function isAutomaticallySubscribed($phid) {

View file

@ -12,7 +12,7 @@ final class PhabricatorMacroTransaction
} }
public function getApplicationTransactionType() { public function getApplicationTransactionType() {
return PhabricatorPHIDConstants::PHID_TYPE_MCRO; return PhabricatorMacroPHIDTypeMacro::TYPECONST;
} }
public function getApplicationTransactionCommentObject() { public function getApplicationTransactionCommentObject() {

View file

@ -109,7 +109,6 @@ final class PhabricatorObjectHandle
static $map = array( static $map = array(
PhabricatorPHIDConstants::PHID_TYPE_USER => 'User', PhabricatorPHIDConstants::PHID_TYPE_USER => 'User',
PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'Image Macro',
PhabricatorPHIDConstants::PHID_TYPE_PIMG => 'Pholio Image', PhabricatorPHIDConstants::PHID_TYPE_PIMG => 'Pholio Image',
PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog', PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog',
PhabricatorPHIDConstants::PHID_TYPE_POST => 'Post', PhabricatorPHIDConstants::PHID_TYPE_POST => 'Post',

View file

@ -18,7 +18,6 @@ final class PhabricatorPHIDConstants {
const PHID_TYPE_BLOG = 'BLOG'; const PHID_TYPE_BLOG = 'BLOG';
const PHID_TYPE_ANSW = 'ANSW'; const PHID_TYPE_ANSW = 'ANSW';
const PHID_TYPE_PIMG = 'PIMG'; const PHID_TYPE_PIMG = 'PIMG';
const PHID_TYPE_MCRO = 'MCRO';
const PHID_TYPE_CONP = 'CONP'; const PHID_TYPE_CONP = 'CONP';
const PHID_TYPE_PVAR = 'PVAR'; const PHID_TYPE_PVAR = 'PVAR';
const PHID_TYPE_ACNT = 'ACNT'; const PHID_TYPE_ACNT = 'ACNT';

View file

@ -89,7 +89,7 @@ final class PhabricatorObjectHandleData {
->execute(); ->execute();
$xactions += mpull($results, null, 'getPHID'); $xactions += mpull($results, null, 'getPHID');
break; break;
case PhabricatorPHIDConstants::PHID_TYPE_MCRO: case PhabricatorMacroPHIDTypeMacro::TYPECONST:
$results = id(new PhabricatorMacroTransactionQuery()) $results = id(new PhabricatorMacroTransactionQuery())
->setViewer($this->viewer) ->setViewer($this->viewer)
->withPHIDs($subtype_phids) ->withPHIDs($subtype_phids)
@ -100,13 +100,6 @@ final class PhabricatorObjectHandleData {
} }
return mpull($xactions, null, 'getPHID'); 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: case PhabricatorPHIDConstants::PHID_TYPE_BLOG:
$blogs = id(new PhameBlogQuery()) $blogs = id(new PhameBlogQuery())
->withPHIDs($phids) ->withPHIDs($phids)
@ -341,24 +334,6 @@ final class PhabricatorObjectHandleData {
} }
break; 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: case PhabricatorPHIDConstants::PHID_TYPE_PVAR:
foreach ($phids as $phid) { foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle(); $handle = new PhabricatorObjectHandle();

View file

@ -159,7 +159,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'PhameBlog', PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'PhameBlog',
PhabricatorPHIDConstants::PHID_TYPE_POST => 'PhamePost', PhabricatorPHIDConstants::PHID_TYPE_POST => 'PhamePost',
PhabricatorPHIDConstants::PHID_TYPE_ANSW => 'PonderAnswer', PhabricatorPHIDConstants::PHID_TYPE_ANSW => 'PonderAnswer',
PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'PhabricatorFileImageMacro',
PhabricatorPHIDConstants::PHID_TYPE_CONP => 'ConpherenceThread', PhabricatorPHIDConstants::PHID_TYPE_CONP => 'ConpherenceThread',
PhabricatorPHIDConstants::PHID_TYPE_ACNT => 'PhortuneAccount', PhabricatorPHIDConstants::PHID_TYPE_ACNT => 'PhortuneAccount',
PhabricatorPHIDConstants::PHID_TYPE_PRCH => 'PhortunePurchase', PhabricatorPHIDConstants::PHID_TYPE_PRCH => 'PhortunePurchase',

View file

@ -237,7 +237,7 @@ final class PHUIFeedStoryView extends AphrontView {
case PholioPHIDTypeMock::TYPECONST: case PholioPHIDTypeMock::TYPECONST:
$this->setAppIcon("pholio-dark"); $this->setAppIcon("pholio-dark");
break; break;
case PhabricatorPHIDConstants::PHID_TYPE_MCRO: case PhabricatorMacroPHIDTypeMacro::TYPECONST:
$this->setAppIcon("macro-dark"); $this->setAppIcon("macro-dark");
break; break;
} }