Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / applications / differential / xaction / DifferentialRevisionHoldDraftTransaction.php
blobcf13e8e5b2962032659886d9b54e419efb0926d1
1 <?php
3 final class DifferentialRevisionHoldDraftTransaction
4 extends DifferentialRevisionTransactionType {
6 const TRANSACTIONTYPE = 'draft';
7 const EDITKEY = 'draft';
9 public function generateOldValue($object) {
10 return (bool)$object->getHoldAsDraft();
13 public function generateNewValue($object, $value) {
14 return (bool)$value;
17 public function applyInternalEffects($object, $value) {
18 $object->setHoldAsDraft($value);
20 // If draft isn't the default state but we're creating a new revision
21 // and holding it as a draft, put it in draft mode. See PHI206.
22 // TODO: This can probably be removed once Draft is the universal default.
23 if ($this->isNewObject()) {
24 if ($object->isNeedsReview()) {
25 $object
26 ->setModernRevisionStatus(DifferentialRevisionStatus::DRAFT)
27 ->setShouldBroadcast(false);
32 public function getTitle() {
33 if ($this->getNewValue()) {
34 return pht(
35 '%s held this revision as a draft.',
36 $this->renderAuthor());
37 } else {
38 return pht(
39 '%s set this revision to automatically submit once builds complete.',
40 $this->renderAuthor());
44 public function getTitleForFeed() {
45 if ($this->getNewValue()) {
46 return pht(
47 '%s held %s as a draft.',
48 $this->renderAuthor(),
49 $this->renderObject());
50 } else {
51 return pht(
52 '%s set %s to automatically submit once builds complete.',
53 $this->renderAuthor(),
54 $this->renderObject());
58 public function getTransactionTypeForConduit($xaction) {
59 return 'draft';
62 public function getFieldValuesForConduit($xaction, $data) {
63 return array(
64 'old' => $xaction->getOldValue(),
65 'new' => $xaction->getNewValue(),