3 final class DifferentialRevisionAuthorTransaction
4 extends DifferentialRevisionTransactionType
{
6 const TRANSACTIONTYPE
= 'differential.revision.author';
7 const EDITKEY
= 'author';
9 public function generateOldValue($object) {
10 return $object->getAuthorPHID();
13 public function generateNewValue($object, $value) {
17 public function applyInternalEffects($object, $value) {
18 $object->setAuthorPHID($value);
21 public function validateTransactions($object, array $xactions) {
22 $actor = $this->getActor();
29 foreach ($xactions as $xaction) {
30 $old = $xaction->generateOldValue($object);
31 $new = $xaction->getNewValue();
38 $errors[] = $this->newInvalidError(
39 pht('Revisions must have an assigned author.'),
44 $author_objects = id(new PhabricatorPeopleQuery())
46 ->withPHIDs(array($new))
48 if (!$author_objects) {
49 $errors[] = $this->newInvalidError(
50 pht('Author "%s" is not a valid user.', $new),
59 public function getIcon() {
60 $author_phid = $this->getAuthorPHID();
61 $old_phid = $this->getOldValue();
62 $new_phid = $this->getNewValue();
64 $is_commandeer = ($author_phid === $new_phid);
65 $is_foist = ($author_phid === $old_phid);
78 public function getColor() {
82 public function getTitle() {
83 $author_phid = $this->getAuthorPHID();
84 $old_phid = $this->getOldValue();
85 $new_phid = $this->getNewValue();
87 $is_commandeer = ($author_phid === $new_phid);
88 $is_foist = ($author_phid === $old_phid);
92 '%s commandeered this revision from %s.',
93 $this->renderAuthor(),
94 $this->renderOldHandle());
100 '%s foisted this revision upon %s.',
101 $this->renderAuthor(),
102 $this->renderNewHandle());
105 // This isn't a valid transaction that can be applied, but happens in
106 // the preview if you temporarily delete the tokenizer value.
109 '%s foisted this revision upon...',
110 $this->renderAuthor());
115 '%s changed the author of this revision from %s to %s.',
116 $this->renderAuthor(),
117 $this->renderOldHandle(),
118 $this->renderNewHandle());
121 public function getTitleForFeed() {
122 $author_phid = $this->getAuthorPHID();
123 $old_phid = $this->getOldValue();
124 $new_phid = $this->getNewValue();
126 $is_commandeer = ($author_phid === $new_phid);
127 $is_foist = ($author_phid === $old_phid);
129 if ($is_commandeer) {
131 '%s commandeered %s from %s.',
132 $this->renderAuthor(),
133 $this->renderObject(),
134 $this->renderOldHandle());
139 '%s foisted %s upon %s.',
140 $this->renderAuthor(),
141 $this->renderObject(),
142 $this->renderNewHandle());
146 '%s changed the author of %s from %s to %s.',
147 $this->renderAuthor(),
148 $this->renderObject(),
149 $this->renderOldHandle(),
150 $this->renderNewHandle());
154 public function getTransactionTypeForConduit($xaction) {
158 public function getFieldValuesForConduit($object, $data) {
160 'old' => $object->getOldValue(),
161 'new' => $object->getNewValue(),