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);
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);
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) {
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(
57 'Webhook status "%s" is not valid. Valid statuses are: %s.',
59 implode(', ', array_keys($options))),