mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
9d56a3d86e
Test Plan: owls Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17671
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
final class PhabricatorCountdownEpochTransaction
|
|
extends PhabricatorCountdownTransactionType {
|
|
|
|
const TRANSACTIONTYPE = 'countdown:epoch';
|
|
|
|
public function generateOldValue($object) {
|
|
return (int)$object->getEpoch();
|
|
}
|
|
|
|
public function generateNewValue($object, $value) {
|
|
return $value->newPhutilDateTime()
|
|
->newAbsoluteDateTime()
|
|
->getEpoch();
|
|
}
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
$object->setEpoch($value);
|
|
}
|
|
|
|
public function getTitle() {
|
|
return pht(
|
|
'%s updated the countdown end from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderOldDate(),
|
|
$this->renderNewDate());
|
|
}
|
|
|
|
public function getTitleForFeed() {
|
|
return pht(
|
|
'%s updated the countdown end for %s from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderObject(),
|
|
$this->renderOldDate(),
|
|
$this->renderNewDate());
|
|
}
|
|
|
|
public function validateTransactions($object, array $xactions) {
|
|
$errors = array();
|
|
|
|
if (!$object->getEpoch() && !$xactions) {
|
|
$errors[] = $this->newRequiredError(
|
|
pht('You must give the countdown an end date.'));
|
|
return $errors;
|
|
}
|
|
|
|
foreach ($xactions as $xaction) {
|
|
$value = $xaction->getNewValue();
|
|
if (!$value->isValid()) {
|
|
$errors[] = $this->newInvalidError(
|
|
pht('You must give the countdown an end date.'));
|
|
}
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
}
|