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

When applying repository operations via Drydock, provide more context on OperationType

Summary: Ref T13195. See PHI845. For custom OperationTypes, provide access to the Interface and Operation via getters. This is just for convenience, since passing these around everywhere can be a bit of a pain if you have a deep-ish stack of things or love using callbacks or whatever.

Test Plan: Landed a revision via upstream Drydock operations.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13195

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

+32 -9
+23
src/applications/drydock/operation/DrydockRepositoryOperationType.php
··· 3 3 abstract class DrydockRepositoryOperationType extends Phobject { 4 4 5 5 private $viewer; 6 + private $operation; 7 + private $interface; 6 8 7 9 abstract public function applyOperation( 8 10 DrydockRepositoryOperation $operation, ··· 27 29 28 30 final public function getViewer() { 29 31 return $this->viewer; 32 + } 33 + 34 + final public function setOperation(DrydockRepositoryOperation $operation) { 35 + $this->operation = $operation; 36 + return $this; 37 + } 38 + 39 + final public function getOperation() { 40 + return $this->operation; 41 + } 42 + 43 + final public function setInterface(DrydockInterface $interface) { 44 + $this->interface = $interface; 45 + return $this; 46 + } 47 + 48 + final public function getInterface() { 49 + if (!$this->interface) { 50 + throw new PhutilInvalidStateException('setInterface'); 51 + } 52 + return $this->interface; 30 53 } 31 54 32 55 final public function getOperationConstant() {
+6 -1
src/applications/drydock/query/DrydockRepositoryOperationQuery.php
··· 62 62 protected function willFilterPage(array $operations) { 63 63 $implementations = DrydockRepositoryOperationType::getAllOperationTypes(); 64 64 65 + $viewer = $this->getViewer(); 66 + 65 67 foreach ($operations as $key => $operation) { 66 68 $impl = idx($implementations, $operation->getOperationType()); 67 69 if (!$impl) { ··· 69 71 unset($operations[$key]); 70 72 continue; 71 73 } 72 - $impl = clone $impl; 74 + $impl = id(clone $impl) 75 + ->setViewer($viewer) 76 + ->setOperation($operation); 77 + 73 78 $operation->attachImplementation($impl); 74 79 } 75 80
+3 -3
src/applications/drydock/storage/DrydockRepositoryOperation.php
··· 137 137 } 138 138 139 139 public function applyOperation(DrydockInterface $interface) { 140 - return $this->getImplementation()->applyOperation( 141 - $this, 142 - $interface); 140 + $impl = $this->getImplementation(); 141 + $impl->setInterface($interface); 142 + return $impl->applyOperation($this, $interface); 143 143 } 144 144 145 145 public function getOperationDescription(PhabricatorUser $viewer) {
-5
src/applications/drydock/worker/DrydockRepositoryOperationUpdateWorker.php
··· 25 25 26 26 27 27 private function handleUpdate(DrydockRepositoryOperation $operation) { 28 - $viewer = $this->getViewer(); 29 - 30 28 $operation_state = $operation->getOperationState(); 31 29 32 30 switch ($operation_state) { ··· 53 51 // waiting for a lease we're holding. 54 52 55 53 try { 56 - $operation->getImplementation() 57 - ->setViewer($viewer); 58 - 59 54 $lease = $this->loadWorkingCopyLease($operation); 60 55 61 56 $interface = $lease->getInterface(