@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.

Implement PhabricatorApplicationTransactionInterface in Differential

Summary:
Ref T4810. Ultimate goal is to let Harbormaster post a "build passed/failed" transaction. To prepare for that, implement `PhabricatorApplicationTransactionInterface` in Differential.

To allow Harbormaster to take action on //diffs// but have the transactions apply to //revisions//, I added a new method so that objects can redirect transactions to some other object.

Test Plan:
- Subscribed/unsubscribed/attached/detached from Differential, saw transactions appear properly.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4810

Differential Revision: https://secure.phabricator.com/D8802

+99 -6
+2
src/__phutil_library_map__.php
··· 2951 2951 0 => 'DifferentialDAO', 2952 2952 1 => 'PhabricatorPolicyInterface', 2953 2953 2 => 'HarbormasterBuildableInterface', 2954 + 3 => 'PhabricatorApplicationTransactionInterface', 2954 2955 ), 2955 2956 'DifferentialDiffCreateController' => 'DifferentialController', 2956 2957 'DifferentialDiffProperty' => 'DifferentialDAO', ··· 3015 3016 5 => 'HarbormasterBuildableInterface', 3016 3017 6 => 'PhabricatorSubscribableInterface', 3017 3018 7 => 'PhabricatorCustomFieldInterface', 3019 + 8 => 'PhabricatorApplicationTransactionInterface', 3018 3020 ), 3019 3021 'DifferentialRevisionDetailView' => 'AphrontView', 3020 3022 'DifferentialRevisionEditController' => 'DifferentialController',
+28 -1
src/applications/differential/storage/DifferentialDiff.php
··· 4 4 extends DifferentialDAO 5 5 implements 6 6 PhabricatorPolicyInterface, 7 - HarbormasterBuildableInterface { 7 + HarbormasterBuildableInterface, 8 + PhabricatorApplicationTransactionInterface { 8 9 9 10 protected $revisionID; 10 11 protected $authorPHID; ··· 347 348 } 348 349 349 350 return null; 351 + } 352 + 353 + 354 + /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 355 + 356 + 357 + public function getApplicationTransactionEditor() { 358 + if (!$this->getRevisionID()) { 359 + return null; 360 + } 361 + return $this->getRevision()->getApplicationTransactionEditor(); 362 + } 363 + 364 + 365 + public function getApplicationTransactionObject() { 366 + if (!$this->getRevisionID()) { 367 + return null; 368 + } 369 + return $this->getRevision(); 370 + } 371 + 372 + public function getApplicationTransactionTemplate() { 373 + if (!$this->getRevisionID()) { 374 + return null; 375 + } 376 + return $this->getRevision()->getApplicationTransactionTemplate(); 350 377 } 351 378 352 379 }
+18 -1
src/applications/differential/storage/DifferentialRevision.php
··· 8 8 PhrequentTrackableInterface, 9 9 HarbormasterBuildableInterface, 10 10 PhabricatorSubscribableInterface, 11 - PhabricatorCustomFieldInterface { 11 + PhabricatorCustomFieldInterface, 12 + PhabricatorApplicationTransactionInterface { 12 13 13 14 protected $title = ''; 14 15 protected $originalTitle; ··· 458 459 public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { 459 460 $this->customFields = $fields; 460 461 return $this; 462 + } 463 + 464 + 465 + /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 466 + 467 + 468 + public function getApplicationTransactionEditor() { 469 + return new DifferentialTransactionEditor(); 470 + } 471 + 472 + public function getApplicationTransactionObject() { 473 + return $this; 474 + } 475 + 476 + public function getApplicationTransactionTemplate() { 477 + return new DifferentialTransaction(); 461 478 } 462 479 463 480 }
+5
src/applications/legalpad/storage/LegalpadDocument.php
··· 145 145 146 146 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 147 147 148 + 148 149 public function getApplicationTransactionEditor() { 149 150 return new LegalpadDocumentEditor(); 150 151 } 151 152 152 153 public function getApplicationTransactionObject() { 154 + return $this; 155 + } 156 + 157 + public function getApplicationTransactionTemplate() { 153 158 return new LegalpadTransaction(); 154 159 } 155 160
+4
src/applications/macro/storage/PhabricatorFileImageMacro.php
··· 68 68 } 69 69 70 70 public function getApplicationTransactionObject() { 71 + return $this; 72 + } 73 + 74 + public function getApplicationTransactionTemplate() { 71 75 return new PhabricatorMacroTransaction(); 72 76 } 73 77
+4
src/applications/pholio/storage/PholioMock.php
··· 219 219 } 220 220 221 221 public function getApplicationTransactionObject() { 222 + return $this; 223 + } 224 + 225 + public function getApplicationTransactionTemplate() { 222 226 return new PholioTransaction(); 223 227 } 224 228
+4 -2
src/applications/search/controller/PhabricatorSearchAttachController.php
··· 70 70 $txn_editor = $object->getApplicationTransactionEditor() 71 71 ->setActor($user) 72 72 ->setContentSourceFromRequest($request); 73 - $txn_template = $object->getApplicationTransactionObject() 73 + $txn_template = $object->getApplicationTransactionTemplate() 74 74 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 75 75 ->setMetadataValue('edge:type', $edge_type) 76 76 ->setNewValue(array( 77 77 '+' => array_fuse($add_phids), 78 78 '-' => array_fuse($rem_phids))); 79 - $txn_editor->applyTransactions($object, array($txn_template)); 79 + $txn_editor->applyTransactions( 80 + $object->getApplicationTransactionObject(), 81 + array($txn_template)); 80 82 81 83 } else { 82 84
+4 -2
src/applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php
··· 74 74 ); 75 75 } 76 76 77 - $xaction = id($object->getApplicationTransactionObject()) 77 + $xaction = id($object->getApplicationTransactionTemplate()) 78 78 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) 79 79 ->setNewValue($xaction_value); 80 80 ··· 83 83 ->setContinueOnNoEffect(true) 84 84 ->setContentSourceFromRequest($request); 85 85 86 - $editor->applyTransactions($object, array($xaction)); 86 + $editor->applyTransactions( 87 + $object->getApplicationTransactionObject(), 88 + array($xaction)); 87 89 } else { 88 90 89 91 // TODO: Eventually, get rid of this once everything implements
+30
src/applications/transactions/interface/PhabricatorApplicationTransactionInterface.php
··· 1 1 <?php 2 2 3 + /** 4 + * Allow infrastructure to apply transactions to the implementing object. 5 + * 6 + * For example, implementing this interface allows Subscriptions to apply CC 7 + * transactions, and allows Harbormaster to apply build result notifications. 8 + */ 3 9 interface PhabricatorApplicationTransactionInterface { 4 10 11 + /** 12 + * Return a @{class:PhabricatorApplicationTransactionEditor} which can be 13 + * used to apply transactions to this object. 14 + * 15 + * @return PhabricatorApplicationTransactionEditor Editor for this object. 16 + */ 5 17 public function getApplicationTransactionEditor(); 18 + 19 + 20 + /** 21 + * Return the object to apply transactions to. Normally this is the current 22 + * object (that is, `$this`), but in some cases transactions may apply to 23 + * a different object: for example, @{class:DifferentialDiff} applies 24 + * transactions to the associated @{class:DifferentialRevision}. 25 + * 26 + * @return PhabricatorLiskDAO Object to apply transactions to. 27 + */ 6 28 public function getApplicationTransactionObject(); 29 + 30 + 31 + /** 32 + * Return a template transaction for this object. 33 + * 34 + * @return PhabricatorApplicationTransaction 35 + */ 36 + public function getApplicationTransactionTemplate(); 7 37 8 38 }