@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 HeraldRuleEditTransaction
4 extends HeraldRuleTransactionType {
5
6 const TRANSACTIONTYPE = 'herald:edit';
7
8 public function generateOldValue($object) {
9 return id(new HeraldRuleSerializer())
10 ->serializeRule($object);
11 }
12
13 public function applyInternalEffects($object, $value) {
14 $new_state = id(new HeraldRuleSerializer())
15 ->deserializeRuleComponents($value);
16
17 $object->setMustMatchAll((int)$new_state['match_all']);
18 $object->attachConditions($new_state['conditions']);
19 $object->attachActions($new_state['actions']);
20
21 $new_repetition = $new_state['repetition_policy'];
22 $object->setRepetitionPolicyStringConstant($new_repetition);
23 }
24
25 public function applyExternalEffects($object, $value) {
26 $object->saveConditions($object->getConditions());
27 $object->saveActions($object->getActions());
28 }
29
30 public function getTitle() {
31 return pht(
32 '%s edited this rule.',
33 $this->renderAuthor());
34 }
35
36 public function hasChangeDetailView() {
37 return true;
38 }
39
40 public function newChangeDetailView() {
41 $viewer = $this->getViewer();
42
43 return id(new PhabricatorApplicationTransactionJSONDiffDetailView())
44 ->setViewer($viewer)
45 ->setOld($this->getOldValue())
46 ->setNew($this->getNewValue());
47 }
48
49}