Differential D18748 Diff 45004 src/applications/differential/editor/DifferentialTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialTransactionEditor.php
<?php | <?php | ||||
final class DifferentialTransactionEditor | final class DifferentialTransactionEditor | ||||
extends PhabricatorApplicationTransactionEditor { | extends PhabricatorApplicationTransactionEditor { | ||||
private $changedPriorToCommitURI; | private $changedPriorToCommitURI; | ||||
private $isCloseByCommit; | private $isCloseByCommit; | ||||
private $repositoryPHIDOverride = false; | private $repositoryPHIDOverride = false; | ||||
private $didExpandInlineState = false; | private $didExpandInlineState = false; | ||||
private $hasReviewTransaction = false; | private $hasReviewTransaction = false; | ||||
private $affectedPaths; | private $affectedPaths; | ||||
private $firstBroadcast = false; | |||||
public function getEditorApplicationClass() { | public function getEditorApplicationClass() { | ||||
return 'PhabricatorDifferentialApplication'; | return 'PhabricatorDifferentialApplication'; | ||||
} | } | ||||
public function getEditorObjectsDescription() { | public function getEditorObjectsDescription() { | ||||
return pht('Differential Revisions'); | return pht('Differential Revisions'); | ||||
} | } | ||||
public function getCreateObjectTitle($author, $object) { | public function getCreateObjectTitle($author, $object) { | ||||
return pht('%s created this revision.', $author); | return pht('%s created this revision.', $author); | ||||
} | } | ||||
public function getCreateObjectTitleForFeed($author, $object) { | public function getCreateObjectTitleForFeed($author, $object) { | ||||
return pht('%s created %s.', $author, $object); | return pht('%s created %s.', $author, $object); | ||||
} | } | ||||
public function isFirstBroadcast() { | public function isFirstBroadcast() { | ||||
return $this->getIsNewObject(); | return $this->firstBroadcast; | ||||
} | } | ||||
public function getDiffUpdateTransaction(array $xactions) { | public function getDiffUpdateTransaction(array $xactions) { | ||||
$type_update = DifferentialTransaction::TYPE_UPDATE; | $type_update = DifferentialTransaction::TYPE_UPDATE; | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
if ($xaction->getTransactionType() == $type_update) { | if ($xaction->getTransactionType() == $type_update) { | ||||
return $xaction; | return $xaction; | ||||
▲ Show 20 Lines • Show All 1,405 Lines • ▼ Show 20 Lines | return id(new DifferentialRevisionQuery()) | ||||
->needActiveDiffs(true) | ->needActiveDiffs(true) | ||||
->withIDs(array($object->getID())) | ->withIDs(array($object->getID())) | ||||
->executeOne(); | ->executeOne(); | ||||
} | } | ||||
protected function getCustomWorkerState() { | protected function getCustomWorkerState() { | ||||
return array( | return array( | ||||
'changedPriorToCommitURI' => $this->changedPriorToCommitURI, | 'changedPriorToCommitURI' => $this->changedPriorToCommitURI, | ||||
'firstBroadcast' => $this->firstBroadcast, | |||||
); | ); | ||||
} | } | ||||
protected function loadCustomWorkerState(array $state) { | protected function loadCustomWorkerState(array $state) { | ||||
$this->changedPriorToCommitURI = idx($state, 'changedPriorToCommitURI'); | $this->changedPriorToCommitURI = idx($state, 'changedPriorToCommitURI'); | ||||
$this->firstBroadcast = idx($state, 'firstBroadcast'); | |||||
return $this; | return $this; | ||||
} | } | ||||
private function newCommandeerReviewerTransaction( | private function newCommandeerReviewerTransaction( | ||||
DifferentialRevision $revision) { | DifferentialRevision $revision) { | ||||
$actor_phid = $this->getActingAsPHID(); | $actor_phid = $this->getActingAsPHID(); | ||||
$owner_phid = $revision->getAuthorPHID(); | $owner_phid = $revision->getAuthorPHID(); | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | protected function didApplyTransactions($object, array $xactions) { | ||||
if ($object->isDraft() && $auto_undraft) { | if ($object->isDraft() && $auto_undraft) { | ||||
$active_builds = $this->hasActiveBuilds($object); | $active_builds = $this->hasActiveBuilds($object); | ||||
if (!$active_builds) { | if (!$active_builds) { | ||||
// When Harbormaster moves a revision out of the draft state, we | // When Harbormaster moves a revision out of the draft state, we | ||||
// attribute the action to the revision author since this is more | // attribute the action to the revision author since this is more | ||||
// natural and more useful. | // natural and more useful. | ||||
$author_phid = $object->getAuthorPHID(); | $author_phid = $object->getAuthorPHID(); | ||||
// Additionally, we change the acting PHID for the transaction set | |||||
// to the author if it isn't already a user so that mail comes from | |||||
// the natural author. | |||||
$acting_phid = $this->getActingAsPHID(); | |||||
$user_type = PhabricatorPeopleUserPHIDType::TYPECONST; | |||||
if (phid_get_type($acting_phid) != $user_type) { | |||||
$this->setActingAsPHID($author_phid); | |||||
} | |||||
// Mark this as the first broadcast we're sending about the revision | |||||
// so mail can generate specially. | |||||
$this->firstBroadcast = true; | |||||
$xaction = $object->getApplicationTransactionTemplate() | $xaction = $object->getApplicationTransactionTemplate() | ||||
->setAuthorPHID($author_phid) | ->setAuthorPHID($author_phid) | ||||
->setTransactionType( | ->setTransactionType( | ||||
DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE) | DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE) | ||||
->setOldValue(false) | ->setOldValue(false) | ||||
->setNewValue(true); | ->setNewValue(true); | ||||
$xaction = $this->populateTransaction($object, $xaction); | $xaction = $this->populateTransaction($object, $xaction); | ||||
Show All 37 Lines |