Path: blob/master/src/applications/herald/xaction/HeraldWebhookStatusTransaction.php
12256 views
<?php12final class HeraldWebhookStatusTransaction3extends HeraldWebhookTransactionType {45const TRANSACTIONTYPE = 'status';67public function generateOldValue($object) {8return $object->getStatus();9}1011public function applyInternalEffects($object, $value) {12$object->setStatus($value);13}1415public function getTitle() {16$old_value = $this->getOldValue();17$new_value = $this->getNewValue();1819$old_status = HeraldWebhook::getDisplayNameForStatus($old_value);20$new_status = HeraldWebhook::getDisplayNameForStatus($new_value);2122return pht(23'%s changed hook status from %s to %s.',24$this->renderAuthor(),25$this->renderValue($old_status),26$this->renderValue($new_status));27}2829public function getTitleForFeed() {30$old_value = $this->getOldValue();31$new_value = $this->getNewValue();3233$old_status = HeraldWebhook::getDisplayNameForStatus($old_value);34$new_status = HeraldWebhook::getDisplayNameForStatus($new_value);3536return pht(37'%s changed %s from %s to %s.',38$this->renderAuthor(),39$this->renderObject(),40$this->renderValue($old_status),41$this->renderValue($new_status));42}4344public function validateTransactions($object, array $xactions) {45$errors = array();46$viewer = $this->getActor();4748$options = HeraldWebhook::getStatusDisplayNameMap();4950foreach ($xactions as $xaction) {51$new_value = $xaction->getNewValue();5253if (!isset($options[$new_value])) {54$errors[] = $this->newInvalidError(55pht(56'Webhook status "%s" is not valid. Valid statuses are: %s.',57$new_value,58implode(', ', array_keys($options))),59$xaction);60}61}6263return $errors;64}6566}676869