@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+80 -32
+2
src/__phutil_library_map__.php
··· 1200 1200 'PhabricatorJumpNavHandler' => 'applications/search/engine/PhabricatorJumpNavHandler.php', 1201 1201 'PhabricatorKeyValueDatabaseCache' => 'applications/cache/PhabricatorKeyValueDatabaseCache.php', 1202 1202 'PhabricatorLegalpadConfigOptions' => 'applications/legalpad/config/PhabricatorLegalpadConfigOptions.php', 1203 + 'PhabricatorLegalpadPHIDTypeDocument' => 'applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php', 1203 1204 'PhabricatorLintEngine' => 'infrastructure/lint/PhabricatorLintEngine.php', 1204 1205 'PhabricatorLipsumArtist' => 'applications/lipsum/image/PhabricatorLipsumArtist.php', 1205 1206 'PhabricatorLipsumGenerateWorkflow' => 'applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php', ··· 3222 3223 'PhabricatorJavelinLinter' => 'ArcanistLinter', 3223 3224 'PhabricatorKeyValueDatabaseCache' => 'PhutilKeyValueCache', 3224 3225 'PhabricatorLegalpadConfigOptions' => 'PhabricatorApplicationConfigOptions', 3226 + 'PhabricatorLegalpadPHIDTypeDocument' => 'PhabricatorPHIDType', 3225 3227 'PhabricatorLintEngine' => 'PhutilLintEngine', 3226 3228 'PhabricatorLipsumGenerateWorkflow' => 'PhabricatorLipsumManagementWorkflow', 3227 3229 'PhabricatorLipsumManagementWorkflow' => 'PhutilArgumentWorkflow',
+76
src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php
··· 1 + <?php 2 + 3 + /** 4 + * @group legalpad 5 + */ 6 + final class PhabricatorLegalpadPHIDTypeDocument extends PhabricatorPHIDType { 7 + 8 + const TYPECONST = 'LEGD'; 9 + 10 + public function getTypeConstant() { 11 + return self::TYPECONST; 12 + } 13 + 14 + public function getTypeName() { 15 + return pht('Legalpad Document'); 16 + } 17 + 18 + public function newObject() { 19 + return new LegalpadDocument(); 20 + } 21 + 22 + public function loadObjects( 23 + PhabricatorObjectQuery $query, 24 + array $phids) { 25 + 26 + return id(new LegalpadDocumentQuery()) 27 + ->needDocumentBodies(true) 28 + ->withPHIDs($phids) 29 + ->setViewer($query->getViewer()) 30 + ->execute(); 31 + } 32 + 33 + public function loadHandles( 34 + PhabricatorHandleQuery $query, 35 + array $handles, 36 + array $objects) { 37 + 38 + foreach ($handles as $phid => $handle) { 39 + $document = $objects[$phid]; 40 + $name = $document->getDocumentBody()->getTitle(); 41 + $handle->setName($name); 42 + $handle->setFullName($name); 43 + $handle->setURI('/legalpad/view/'.$document->getID().'/'); 44 + } 45 + } 46 + 47 + public function canLoadNamedObject($name) { 48 + return preg_match('/^L\d*[1-9]\d*$/i', $name); 49 + } 50 + 51 + public function loadNamedObjects( 52 + PhabricatorObjectQuery $query, 53 + array $names) { 54 + 55 + $id_map = array(); 56 + foreach ($names as $name) { 57 + $id = (int)substr($name, 1); 58 + $id_map[$id][] = $name; 59 + } 60 + 61 + $objects = id(new LegalpadDocumentQuery()) 62 + ->setViewer($query->getViewer()) 63 + ->withIDs(array_keys($id_map)) 64 + ->execute(); 65 + 66 + $results = array(); 67 + foreach ($objects as $id => $object) { 68 + foreach (idx($id_map, $id, array()) as $name) { 69 + $results[$name] = $object; 70 + } 71 + } 72 + 73 + return $results; 74 + } 75 + 76 + }
+1 -1
src/applications/legalpad/storage/LegalpadDocument.php
··· 34 34 35 35 public function generatePHID() { 36 36 return PhabricatorPHID::generateNewPHID( 37 - PhabricatorPHIDConstants::PHID_TYPE_LEGD); 37 + PhabricatorLegalpadPHIDTypeDocument::TYPECONST); 38 38 } 39 39 40 40 public function getDocumentBody() {
+1 -1
src/applications/legalpad/storage/LegalpadTransaction.php
··· 10 10 } 11 11 12 12 public function getApplicationTransactionType() { 13 - return PhabricatorPHIDConstants::PHID_TYPE_LEGD; 13 + return PhabricatorLegalpadPHIDTypeDocument::TYPECONST; 14 14 } 15 15 16 16 public function getApplicationTransactionCommentObject() {
-1
src/applications/phid/PhabricatorObjectHandle.php
··· 111 111 PhabricatorPHIDConstants::PHID_TYPE_USER => 'User', 112 112 PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'Blog', 113 113 PhabricatorPHIDConstants::PHID_TYPE_POST => 'Post', 114 - PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'Legalpad Document', 115 114 ); 116 115 117 116 return idx($map, $this->getType(), $this->getType());
-1
src/applications/phid/PhabricatorPHIDConstants.php
··· 23 23 const PHID_TYPE_PAYM = 'PAYM'; 24 24 const PHID_TYPE_CHRG = 'CHRG'; 25 25 const PHID_TYPE_CART = 'CART'; 26 - const PHID_TYPE_LEGD = 'LEGD'; 27 26 const PHID_TYPE_LEGB = 'LEGB'; 28 27 29 28 const PHID_TYPE_XACT = 'XACT';
-27
src/applications/phid/handle/PhabricatorObjectHandleData.php
··· 104 104 ->execute(); 105 105 return mpull($posts, null, 'getPHID'); 106 106 107 - case PhabricatorPHIDConstants::PHID_TYPE_LEGD: 108 - $legds = id(new LegalpadDocumentQuery()) 109 - ->needDocumentBodies(true) 110 - ->withPHIDs($phids) 111 - ->setViewer($this->viewer) 112 - ->execute(); 113 - return mpull($legds, null, 'getPHID'); 114 - 115 107 case PhabricatorPHIDConstants::PHID_TYPE_CONP: 116 108 $confs = id(new ConpherenceThreadQuery()) 117 109 ->withPHIDs($phids) 118 110 ->setViewer($this->viewer) 119 111 ->execute(); 120 112 return mpull($confs, null, 'getPHID'); 121 - 122 113 123 114 } 124 115 ··· 268 259 $handle->setName($post->getTitle()); 269 260 $handle->setFullName($post->getTitle()); 270 261 $handle->setURI('/phame/post/view/'.$post->getID().'/'); 271 - $handle->setComplete(true); 272 - } 273 - $handles[$phid] = $handle; 274 - } 275 - break; 276 - 277 - case PhabricatorPHIDConstants::PHID_TYPE_LEGD: 278 - foreach ($phids as $phid) { 279 - $handle = new PhabricatorObjectHandle(); 280 - $handle->setPHID($phid); 281 - $handle->setType($type); 282 - if (empty($objects[$phid])) { 283 - $handle->setName(pht('Unknown Legalpad Document')); 284 - } else { 285 - $document = $objects[$phid]; 286 - $handle->setName($document->getDocumentBody()->getTitle()); 287 - $handle->setFullName($document->getDocumentBody()->getTitle()); 288 - $handle->setURI('/legalpad/view/'.$document->getID().'/'); 289 262 $handle->setComplete(true); 290 263 } 291 264 $handles[$phid] = $handle;
-1
src/infrastructure/edges/constants/PhabricatorEdgeConfig.php
··· 164 164 PhabricatorPHIDConstants::PHID_TYPE_PRCH => 'PhortunePurchase', 165 165 PhabricatorPHIDConstants::PHID_TYPE_CHRG => 'PhortuneCharge', 166 166 PhabricatorPHIDConstants::PHID_TYPE_XOBJ => 'DoorkeeperExternalObject', 167 - PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'LegalpadDocument', 168 167 ); 169 168 170 169 $class = idx($class_map, $phid_type);