@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 PholioImageSequenceTransaction
4 extends PholioImageTransactionType {
5
6 const TRANSACTIONTYPE = 'image-sequence';
7
8 public function generateOldValue($object) {
9 $sequence = null;
10 $phid = null;
11 $image = $this->getImageForXaction($object);
12 if ($image) {
13 $sequence = $image->getSequence();
14 $phid = $image->getPHID();
15 }
16 return array($phid => $sequence);
17 }
18
19 public function applyInternalEffects($object, $value) {
20 $image = $this->getImageForXaction($object);
21 $value = (int)head($this->getNewValue());
22 $image->setSequence($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) sequence.',
31 $this->renderAuthor(),
32 $this->renderHandle(head_key($new)));
33 }
34
35 public function getTitleForFeed() {
36 return pht(
37 '%s updated image sequence of %s.',
38 $this->renderAuthor(),
39 $this->renderObject());
40 }
41
42 public function shouldHide() {
43 // this is boring / silly to surface; changing sequence is NBD
44 return true;
45 }
46
47 public function mergeTransactions(
48 $object,
49 PhabricatorApplicationTransaction $u,
50 PhabricatorApplicationTransaction $v) {
51 $raw_new_value_u = $u->getNewValue();
52 $raw_new_value_v = $v->getNewValue();
53 $phid_u = key($raw_new_value_u);
54 $phid_v = key($raw_new_value_v);
55 if ($phid_u == $phid_v) {
56 return $v;
57 }
58 }
59
60}