Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / herald / xaction / HeraldWebhookStatusTransaction.php
blob951001e0b669a09f7a5c199e11e4d23cf16e5b4b
1 <?php
3 final class HeraldWebhookStatusTransaction
4 extends HeraldWebhookTransactionType {
6 const TRANSACTIONTYPE = 'status';
8 public function generateOldValue($object) {
9 return $object->getStatus();
12 public function applyInternalEffects($object, $value) {
13 $object->setStatus($value);
16 public function getTitle() {
17 $old_value = $this->getOldValue();
18 $new_value = $this->getNewValue();
20 $old_status = HeraldWebhook::getDisplayNameForStatus($old_value);
21 $new_status = HeraldWebhook::getDisplayNameForStatus($new_value);
23 return pht(
24 '%s changed hook status from %s to %s.',
25 $this->renderAuthor(),
26 $this->renderValue($old_status),
27 $this->renderValue($new_status));
30 public function getTitleForFeed() {
31 $old_value = $this->getOldValue();
32 $new_value = $this->getNewValue();
34 $old_status = HeraldWebhook::getDisplayNameForStatus($old_value);
35 $new_status = HeraldWebhook::getDisplayNameForStatus($new_value);
37 return pht(
38 '%s changed %s from %s to %s.',
39 $this->renderAuthor(),
40 $this->renderObject(),
41 $this->renderValue($old_status),
42 $this->renderValue($new_status));
45 public function validateTransactions($object, array $xactions) {
46 $errors = array();
47 $viewer = $this->getActor();
49 $options = HeraldWebhook::getStatusDisplayNameMap();
51 foreach ($xactions as $xaction) {
52 $new_value = $xaction->getNewValue();
54 if (!isset($options[$new_value])) {
55 $errors[] = $this->newInvalidError(
56 pht(
57 'Webhook status "%s" is not valid. Valid statuses are: %s.',
58 $new_value,
59 implode(', ', array_keys($options))),
60 $xaction);
64 return $errors;