@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 PhabricatorProjectIconTransaction
4 extends PhabricatorProjectTransactionType {
5
6 const TRANSACTIONTYPE = 'project:icon';
7
8 public function generateOldValue($object) {
9 return $object->getIcon();
10 }
11
12 public function applyInternalEffects($object, $value) {
13 $object->setIcon($value);
14 }
15
16 public function getTitle() {
17 $set = new PhabricatorProjectIconSet();
18 $new = $this->getNewValue();
19
20 return pht(
21 "%s set this project's icon to %s.",
22 $this->renderAuthor(),
23 $this->renderValue($set->getIconLabel($new)));
24 }
25
26 public function getTitleForFeed() {
27 $set = new PhabricatorProjectIconSet();
28 $new = $this->getNewValue();
29
30 return pht(
31 '%s set the icon for %s to %s.',
32 $this->renderAuthor(),
33 $this->renderObject(),
34 $this->renderValue($set->getIconLabel($new)));
35 }
36
37 public function getIcon() {
38 $new = $this->getNewValue();
39 return PhabricatorProjectIconSet::getIconIcon($new);
40 }
41
42 public function validateTransactions($object, array $xactions) {
43 $errors = array();
44
45 if (!$xactions) {
46 return $errors;
47 }
48
49 foreach ($xactions as $xaction) {
50 $new_icon = $xaction->getNewValue();
51 if (!PhabricatorProjectIconSet::getIconName($new_icon)) {
52 $errors[] = new PhabricatorApplicationTransactionValidationError(
53 self::TRANSACTIONTYPE,
54 pht('Invalid'),
55 pht(
56 'Value for "%s" is invalid: "%s".',
57 self::TRANSACTIONTYPE,
58 $new_icon));
59 break;
60 }
61 }
62
63 return $errors;
64 }
65
66}