@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 PhabricatorCountdownEpochTransaction
4 extends PhabricatorCountdownTransactionType {
5
6 const TRANSACTIONTYPE = 'countdown:epoch';
7
8 public function generateOldValue($object) {
9 return (int)$object->getEpoch();
10 }
11
12 public function generateNewValue($object, $value) {
13 return $value->newPhutilDateTime()
14 ->newAbsoluteDateTime()
15 ->getEpoch();
16 }
17
18 public function applyInternalEffects($object, $value) {
19 $object->setEpoch($value);
20 }
21
22 public function getTitle() {
23 return pht(
24 '%s updated the countdown end from %s to %s.',
25 $this->renderAuthor(),
26 $this->renderOldDate(),
27 $this->renderNewDate());
28 }
29
30 public function getTitleForFeed() {
31 return pht(
32 '%s updated the countdown end for %s from %s to %s.',
33 $this->renderAuthor(),
34 $this->renderObject(),
35 $this->renderOldDate(),
36 $this->renderNewDate());
37 }
38
39 public function validateTransactions($object, array $xactions) {
40 $errors = array();
41
42 if (!$object->getEpoch() && !$xactions) {
43 $errors[] = $this->newRequiredError(
44 pht('You must give the countdown an end date.'));
45 return $errors;
46 }
47
48 foreach ($xactions as $xaction) {
49 $value = $xaction->getNewValue();
50 if (!$value->isValid()) {
51 $errors[] = $this->newInvalidError(
52 pht('You must give the countdown an end date.'));
53 }
54 }
55
56 return $errors;
57 }
58}