mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
Move LegalpadDocument to new phid stuff
Summary: ref T2715 - apologies btw as I didn't catch the "start from the bottom" ask until recently... :/ Test Plan: phid.query for some legalpad documents... booya. also loaded legalpad. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6576
This commit is contained in:
parent
3ba2f506fe
commit
0a71593e6d
8 changed files with 80 additions and 32 deletions
|
@ -1200,6 +1200,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorJumpNavHandler' => 'applications/search/engine/PhabricatorJumpNavHandler.php',
|
||||
'PhabricatorKeyValueDatabaseCache' => 'applications/cache/PhabricatorKeyValueDatabaseCache.php',
|
||||
'PhabricatorLegalpadConfigOptions' => 'applications/legalpad/config/PhabricatorLegalpadConfigOptions.php',
|
||||
'PhabricatorLegalpadPHIDTypeDocument' => 'applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php',
|
||||
'PhabricatorLintEngine' => 'infrastructure/lint/PhabricatorLintEngine.php',
|
||||
'PhabricatorLipsumArtist' => 'applications/lipsum/image/PhabricatorLipsumArtist.php',
|
||||
'PhabricatorLipsumGenerateWorkflow' => 'applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php',
|
||||
|
@ -3222,6 +3223,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorJavelinLinter' => 'ArcanistLinter',
|
||||
'PhabricatorKeyValueDatabaseCache' => 'PhutilKeyValueCache',
|
||||
'PhabricatorLegalpadConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorLegalpadPHIDTypeDocument' => 'PhabricatorPHIDType',
|
||||
'PhabricatorLintEngine' => 'PhutilLintEngine',
|
||||
'PhabricatorLipsumGenerateWorkflow' => 'PhabricatorLipsumManagementWorkflow',
|
||||
'PhabricatorLipsumManagementWorkflow' => 'PhutilArgumentWorkflow',
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group legalpad
|
||||
*/
|
||||
final class PhabricatorLegalpadPHIDTypeDocument extends PhabricatorPHIDType {
|
||||
|
||||
const TYPECONST = 'LEGD';
|
||||
|
||||
public function getTypeConstant() {
|
||||
return self::TYPECONST;
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Legalpad Document');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new LegalpadDocument();
|
||||
}
|
||||
|
||||
public function loadObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $phids) {
|
||||
|
||||
return id(new LegalpadDocumentQuery())
|
||||
->needDocumentBodies(true)
|
||||
->withPHIDs($phids)
|
||||
->setViewer($query->getViewer())
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function loadHandles(
|
||||
PhabricatorHandleQuery $query,
|
||||
array $handles,
|
||||
array $objects) {
|
||||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$document = $objects[$phid];
|
||||
$name = $document->getDocumentBody()->getTitle();
|
||||
$handle->setName($name);
|
||||
$handle->setFullName($name);
|
||||
$handle->setURI('/legalpad/view/'.$document->getID().'/');
|
||||
}
|
||||
}
|
||||
|
||||
public function canLoadNamedObject($name) {
|
||||
return preg_match('/^L\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 LegalpadDocumentQuery())
|
||||
->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,7 @@ final class LegalpadDocument extends LegalpadDAO
|
|||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
PhabricatorPHIDConstants::PHID_TYPE_LEGD);
|
||||
PhabricatorLegalpadPHIDTypeDocument::TYPECONST);
|
||||
}
|
||||
|
||||
public function getDocumentBody() {
|
||||
|
|
|
@ -10,7 +10,7 @@ final class LegalpadTransaction extends PhabricatorApplicationTransaction {
|
|||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorPHIDConstants::PHID_TYPE_LEGD;
|
||||
return PhabricatorLegalpadPHIDTypeDocument::TYPECONST;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
|
|
|
@ -111,7 +111,6 @@ final class PhabricatorObjectHandle
|
|||
PhabricatorPHIDConstants::PHID_TYPE_USER => 'User',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_POST => 'Post',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'Legalpad Document',
|
||||
);
|
||||
|
||||
return idx($map, $this->getType(), $this->getType());
|
||||
|
|
|
@ -23,7 +23,6 @@ final class PhabricatorPHIDConstants {
|
|||
const PHID_TYPE_PAYM = 'PAYM';
|
||||
const PHID_TYPE_CHRG = 'CHRG';
|
||||
const PHID_TYPE_CART = 'CART';
|
||||
const PHID_TYPE_LEGD = 'LEGD';
|
||||
const PHID_TYPE_LEGB = 'LEGB';
|
||||
|
||||
const PHID_TYPE_XACT = 'XACT';
|
||||
|
|
|
@ -104,14 +104,6 @@ final class PhabricatorObjectHandleData {
|
|||
->execute();
|
||||
return mpull($posts, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
||||
$legds = id(new LegalpadDocumentQuery())
|
||||
->needDocumentBodies(true)
|
||||
->withPHIDs($phids)
|
||||
->setViewer($this->viewer)
|
||||
->execute();
|
||||
return mpull($legds, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_CONP:
|
||||
$confs = id(new ConpherenceThreadQuery())
|
||||
->withPHIDs($phids)
|
||||
|
@ -119,7 +111,6 @@ final class PhabricatorObjectHandleData {
|
|||
->execute();
|
||||
return mpull($confs, null, 'getPHID');
|
||||
|
||||
|
||||
}
|
||||
|
||||
return array();
|
||||
|
@ -274,24 +265,6 @@ final class PhabricatorObjectHandleData {
|
|||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($objects[$phid])) {
|
||||
$handle->setName(pht('Unknown Legalpad Document'));
|
||||
} else {
|
||||
$document = $objects[$phid];
|
||||
$handle->setName($document->getDocumentBody()->getTitle());
|
||||
$handle->setFullName($document->getDocumentBody()->getTitle());
|
||||
$handle->setURI('/legalpad/view/'.$document->getID().'/');
|
||||
$handle->setComplete(true);
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_CONP:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
|
|
|
@ -164,7 +164,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
PhabricatorPHIDConstants::PHID_TYPE_PRCH => 'PhortunePurchase',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_CHRG => 'PhortuneCharge',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_XOBJ => 'DoorkeeperExternalObject',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'LegalpadDocument',
|
||||
);
|
||||
|
||||
$class = idx($class_map, $phid_type);
|
||||
|
|
Loading…
Reference in a new issue