mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
Use application PHIDs in Pholio Mocks
Summary: Ref T2715. Switch mocks to the new stuff. Test Plan: Used `phid.query` and `phid.lookup` to find mocks. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6517
This commit is contained in:
parent
17ee71d896
commit
2ff57f6938
11 changed files with 86 additions and 45 deletions
|
@ -1746,6 +1746,7 @@ phutil_register_library_map(array(
|
|||
'PholioMockMailReceiver' => 'applications/pholio/mail/PholioMockMailReceiver.php',
|
||||
'PholioMockQuery' => 'applications/pholio/query/PholioMockQuery.php',
|
||||
'PholioMockViewController' => 'applications/pholio/controller/PholioMockViewController.php',
|
||||
'PholioPHIDTypeMock' => 'applications/pholio/phid/PholioPHIDTypeMock.php',
|
||||
'PholioRemarkupRule' => 'applications/pholio/remarkup/PholioRemarkupRule.php',
|
||||
'PholioReplyHandler' => 'applications/pholio/mail/PholioReplyHandler.php',
|
||||
'PholioSearchIndexer' => 'applications/pholio/search/PholioSearchIndexer.php',
|
||||
|
@ -3769,6 +3770,7 @@ phutil_register_library_map(array(
|
|||
'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'PholioMockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PholioMockViewController' => 'PholioController',
|
||||
'PholioPHIDTypeMock' => 'PhabricatorPHIDType',
|
||||
'PholioRemarkupRule' => 'PhabricatorRemarkupRuleObject',
|
||||
'PholioReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'PholioSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
|
|
|
@ -111,7 +111,6 @@ final class PhabricatorObjectHandle
|
|||
PhabricatorPHIDConstants::PHID_TYPE_USER => 'User',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'Phriction Document',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'Image Macro',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MOCK => 'Pholio Mock',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_PIMG => 'Pholio Image',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_FILE => 'File',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog',
|
||||
|
|
|
@ -23,7 +23,6 @@ final class PhabricatorPHIDConstants {
|
|||
const PHID_TYPE_BLOG = 'BLOG';
|
||||
const PHID_TYPE_QUES = 'QUES';
|
||||
const PHID_TYPE_ANSW = 'ANSW';
|
||||
const PHID_TYPE_MOCK = 'MOCK';
|
||||
const PHID_TYPE_PIMG = 'PIMG';
|
||||
const PHID_TYPE_MCRO = 'MCRO';
|
||||
const PHID_TYPE_CONF = 'CONF';
|
||||
|
|
|
@ -110,13 +110,6 @@ final class PhabricatorObjectHandleData {
|
|||
->execute();
|
||||
return mpull($questions, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
$mocks = id(new PholioMockQuery())
|
||||
->setViewer($this->viewer)
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
return mpull($mocks, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_PIMG:
|
||||
$images = id(new PholioImage())
|
||||
->loadAllWhere('phid IN (%Ls)', $phids);
|
||||
|
@ -131,7 +124,7 @@ final class PhabricatorObjectHandleData {
|
|||
foreach ($subtypes as $subtype => $subtype_phids) {
|
||||
// TODO: Do this magically.
|
||||
switch ($subtype) {
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
case PholioPHIDTypeMock::TYPECONST:
|
||||
$results = id(new PholioTransactionQuery())
|
||||
->setViewer($this->viewer)
|
||||
->withPHIDs($subtype_phids)
|
||||
|
@ -524,24 +517,6 @@ final class PhabricatorObjectHandleData {
|
|||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($objects[$phid])) {
|
||||
$handle->setName('Unknown Mock');
|
||||
} else {
|
||||
$mock = $objects[$phid];
|
||||
$handle->setName('M'.$mock->getID());
|
||||
$handle->setFullName('M'.$mock->getID().': '.$mock->getName());
|
||||
$handle->setURI('/M'.$mock->getID());
|
||||
$handle->setComplete(true);
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_PIMG:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
|
|
|
@ -44,14 +44,6 @@ final class PhabricatorPHID {
|
|||
return $name;
|
||||
}
|
||||
|
||||
if (preg_match('/^m(\d+)$/i', $name, $match)) {
|
||||
$objects = id(new PholioMockQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($match[1]))
|
||||
->execute();
|
||||
$object = head($objects);
|
||||
}
|
||||
|
||||
if ($object) {
|
||||
return $object->getPHID();
|
||||
}
|
||||
|
|
75
src/applications/pholio/phid/PholioPHIDTypeMock.php
Normal file
75
src/applications/pholio/phid/PholioPHIDTypeMock.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
final class PholioPHIDTypeMock extends PhabricatorPHIDType {
|
||||
|
||||
const TYPECONST = 'MOCK';
|
||||
|
||||
public function getTypeConstant() {
|
||||
return self::TYPECONST;
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Mock');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new PholioMock();
|
||||
}
|
||||
|
||||
public function loadObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $phids) {
|
||||
|
||||
return id(new PholioMockQuery())
|
||||
->setViewer($query->getViewer())
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function loadHandles(
|
||||
PhabricatorHandleQuery $query,
|
||||
array $handles,
|
||||
array $objects) {
|
||||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$mock = $objects[$phid];
|
||||
|
||||
$id = $mock->getID();
|
||||
$name = $mock->getName();
|
||||
|
||||
$handle->setURI("/M{$id}");
|
||||
$handle->setName("M{$id}");
|
||||
$handle->setFullName("M{$id}: {$name}");
|
||||
}
|
||||
}
|
||||
|
||||
public function canLoadNamedObject($name) {
|
||||
return preg_match('/^M\d*[1-9]\d*$/i', $name);
|
||||
}
|
||||
|
||||
public function loadNamedObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $names) {
|
||||
|
||||
$id_map = array();
|
||||
foreach ($names as $name) {
|
||||
$id = (int)substr($name, 1);
|
||||
$id_map[$id][] = $name;
|
||||
}
|
||||
|
||||
$objects = id(new PholioMockQuery())
|
||||
->setViewer($query->getViewer())
|
||||
->withIDs(array_keys($id_map))
|
||||
->execute();
|
||||
|
||||
$results = array();
|
||||
foreach ($objects as $id => $object) {
|
||||
foreach (idx($id_map, $id, array()) as $name) {
|
||||
$results[$name] = $object;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorPHIDConstants::PHID_TYPE_MOCK;
|
||||
return PholioPHIDTypeMock::TYPECONST;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
|
|
|
@ -210,7 +210,7 @@ final class PhabricatorSearchAttachController
|
|||
$noun = 'Commits';
|
||||
$selected = 'created';
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
case PholioPHIDTypeMock::TYPECONST:
|
||||
$noun = 'Mocks';
|
||||
$selected = 'created';
|
||||
break;
|
||||
|
@ -251,7 +251,7 @@ final class PhabricatorSearchAttachController
|
|||
}
|
||||
|
||||
private function getFilters(array $strings) {
|
||||
if ($this->type == PhabricatorPHIDConstants::PHID_TYPE_MOCK) {
|
||||
if ($this->type == PholioPHIDTypeMock::TYPECONST) {
|
||||
$filters = array(
|
||||
'created' => 'Created By Me',
|
||||
'all' => 'All '.$strings['target_plural_noun'],
|
||||
|
@ -272,7 +272,7 @@ final class PhabricatorSearchAttachController
|
|||
$t_cmit = PhabricatorRepositoryPHIDTypeCommit::TYPECONST;
|
||||
$t_task = ManiphestPHIDTypeTask::TYPECONST;
|
||||
$t_drev = DifferentialPHIDTypeRevision::TYPECONST;
|
||||
$t_mock = PhabricatorPHIDConstants::PHID_TYPE_MOCK;
|
||||
$t_mock = PholioPHIDTypeMock::TYPECONST;
|
||||
|
||||
$map = array(
|
||||
$t_cmit => array(
|
||||
|
|
|
@ -33,7 +33,7 @@ final class PhabricatorSearchSelectController
|
|||
$query->setParameter('author', array($user->getPHID()));
|
||||
// TODO - if / when we allow pholio mocks to be archived, etc
|
||||
// update this
|
||||
if ($this->type != PhabricatorPHIDConstants::PHID_TYPE_MOCK) {
|
||||
if ($this->type != PholioPHIDTypeMock::TYPECONST) {
|
||||
$query->setParameter('open', 1);
|
||||
}
|
||||
break;
|
||||
|
@ -73,7 +73,7 @@ final class PhabricatorSearchSelectController
|
|||
case DifferentialPHIDTypeRevision::TYPECONST:
|
||||
$pattern = '/\bD(\d+)\b/i';
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
case PholioPHIDTypeMock::TYPECONST:
|
||||
$pattern = '/\bM(\d+)\b/i';
|
||||
break;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ final class PhabricatorSearchSelectController
|
|||
'id IN (%Ld)',
|
||||
$object_ids);
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
case PholioPHIDTypeMock::TYPECONST:
|
||||
$objects = id(new PholioMock())->loadAllWhere(
|
||||
'id IN (%Ld)',
|
||||
$object_ids);
|
||||
|
|
|
@ -162,7 +162,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
PhabricatorPHIDConstants::PHID_TYPE_POST => 'PhamePost',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_QUES => 'PonderQuestion',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_ANSW => 'PonderAnswer',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MOCK => 'PholioMock',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MCRO => 'PhabricatorFileImageMacro',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_CONP => 'ConpherenceThread',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_WIKI => 'PhrictionDocument',
|
||||
|
|
|
@ -234,7 +234,7 @@ final class PHUIFeedStoryView extends AphrontView {
|
|||
|
||||
public function setAppIconFromPHID($phid) {
|
||||
switch (phid_get_type($phid)) {
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
case PholioPHIDTypeMock::TYPECONST:
|
||||
$this->setAppIcon("pholio-dark");
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MCRO:
|
||||
|
|
Loading…
Reference in a new issue