Differential D17830 Diff 42893 src/applications/slowvote/xactions/PhabricatorSlowvoteCloseTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/xactions/PhabricatorSlowvoteCloseTransaction.php
- This file was added.
<?php | |||||
final class PhabricatorSlowvoteCloseTransaction | |||||
extends PhabricatorSlowvoteTransactionType { | |||||
const TRANSACTIONTYPE = 'vote:close'; | |||||
public function generateOldValue($object) { | |||||
return (bool)$object->getIsClosed(); | |||||
} | |||||
public function generateNewValue($object, $value) { | |||||
return (bool)$value; | |||||
} | |||||
public function applyInternalEffects($object, $value) { | |||||
$object->setIsClosed((int)$value); | |||||
} | |||||
epriestley: Per discussion elsewhere, you //could// use the "two int casts" here instead of "bool + bool +… | |||||
public function getTitle() { | |||||
$new = $this->getNewValue(); | |||||
if ($new) { | |||||
return pht( | |||||
'%s closed this poll.', | |||||
$this->renderAuthor()); | |||||
} else { | |||||
return pht( | |||||
'%s reopened this poll.', | |||||
$this->renderAuthor()); | |||||
} | |||||
} | |||||
public function getTitleForFeed() { | |||||
$new = $this->getNewValue(); | |||||
if ($new) { | |||||
return pht( | |||||
'%s closed %s.', | |||||
$this->renderAuthor(), | |||||
$this->renderObject()); | |||||
} else { | |||||
return pht( | |||||
'%s reopened %s.', | |||||
$this->renderAuthor(), | |||||
$this->renderObject()); | |||||
} | |||||
} | |||||
public function getIcon() { | |||||
$new = $this->getNewValue(); | |||||
if ($new) { | |||||
return 'fa-ban'; | |||||
} else { | |||||
return 'fa-pencil'; | |||||
} | |||||
} | |||||
} | |||||
Done Inline ActionsYou can just omit this method since it doesn't do anything, I think. epriestley: You can just omit this method since it doesn't do anything, I think. |
Per discussion elsewhere, you could use the "two int casts" here instead of "bool + bool + int", but they're basically equivalent.
And "bool + bool + int" is actually better if/when we write a Conduit transaction.search sort of method (read all transactions for an object) since it's cleaner to expose true and false than 1 and 0.
But we might need an indirection layer anyway ("get the API version of this transaction") and that could do all the casts, so who knows.
I think this is basically fine until the day when we eventually have some clarity around MySQL types vs Lisk types vs stored types vs API types. None of this stuff is too terribly difficult to fix retroactively later even if we end up making unexpected decisions.