Differential D17671 Diff 42514 src/applications/countdown/xaction/PhabricatorCountdownEpochTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/countdown/xaction/PhabricatorCountdownEpochTransaction.php
- This file was added.
<?php | |||||
final class PhabricatorCountdownEpochTransaction | |||||
extends PhabricatorCountdownTransactionType { | |||||
const TRANSACTIONTYPE = 'countdown:epoch'; | |||||
public function generateOldValue($object) { | |||||
return (int)$object->getEpoch(); | |||||
} | |||||
epriestley: Just put an `(int)$object->...` cast here... | |||||
public function generateNewValue($object, $value) { | |||||
return $value->newPhutilDateTime() | |||||
->newAbsoluteDateTime() | |||||
->getEpoch(); | |||||
} | |||||
public function applyInternalEffects($object, $value) { | |||||
$object->setEpoch($value); | |||||
} | |||||
Done Inline Actions...and then you should be able to get rid of this. epriestley: ...and then you should be able to get rid of this. | |||||
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) { | |||||
Done Inline ActionsI think you can get rid of this -- this kind of transaction will never generate a separate mail section because it doesn't implement newChangeDetailView(), since it isn't a big block of text that needs a complictated diff to show changes. epriestley: I think you can get rid of this -- this kind of transaction will never generate a separate mail… | |||||
$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.')); | |||||
Done Inline ActionsThis one should be newRequiredError() I think. The difference between "required" and "invalid" is that some edits are allowed to go through even if required fields are missing. For example, you can award a token or subscribe to a countdown even if it somehow has missing information. So generally if a field is empty, but shouldn't be empty, use newRequiredError(). If it has an improper value, use newInvalidError(). epriestley: This one should be `newRequiredError()` I think.
The difference between "required" and… | |||||
} | |||||
} | |||||
return $errors; | |||||
} | |||||
} | |||||
Done Inline Actions(No callers?) epriestley: (No callers?) |
Just put an (int)$object->... cast here...