@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<?php
2
3final class PholioImageDescriptionTransaction
4 extends PholioImageTransactionType {
5
6 const TRANSACTIONTYPE = 'image-description';
7
8 public function generateOldValue($object) {
9 $description = null;
10 $phid = null;
11 $image = $this->getImageForXaction($object);
12 if ($image) {
13 $description = $image->getDescription();
14 $phid = $image->getPHID();
15 }
16 return array($phid => $description);
17 }
18
19 public function applyInternalEffects($object, $value) {
20 $image = $this->getImageForXaction($object);
21 $value = (string)head($this->getNewValue());
22 $image->setDescription($value);
23 $image->save();
24 }
25
26 public function getTitle() {
27 $new = $this->getNewValue();
28
29 return pht(
30 '%s updated an image\'s (%s) description.',
31 $this->renderAuthor(),
32 $this->renderHandle(head_key($new)));
33 }
34
35 public function getTitleForFeed() {
36 return pht(
37 '%s updated image descriptions of %s.',
38 $this->renderAuthor(),
39 $this->renderObject());
40 }
41
42 public function mergeTransactions(
43 $object,
44 PhabricatorApplicationTransaction $u,
45 PhabricatorApplicationTransaction $v) {
46
47 $raw_new_value_u = $u->getNewValue();
48 $raw_new_value_v = $v->getNewValue();
49 $phid_u = head_key($raw_new_value_u);
50 $phid_v = head_key($raw_new_value_v);
51 if ($phid_u == $phid_v) {
52 return $v;
53 }
54
55 return null;
56 }
57
58 public function hasChangeDetailView() {
59 return true;
60 }
61
62 public function newChangeDetailView() {
63 $viewer = $this->getViewer();
64
65 return id(new PhabricatorApplicationTransactionTextDiffDetailView())
66 ->setViewer($viewer)
67 ->setOldText(head($this->getOldValue()))
68 ->setNewText(head($this->getNewValue()));
69 }
70
71}