Path: blob/master/src/applications/herald/xaction/HeraldWebhookNameTransaction.php
12256 views
<?php12final class HeraldWebhookNameTransaction3extends HeraldWebhookTransactionType {45const TRANSACTIONTYPE = 'name';67public function generateOldValue($object) {8return $object->getName();9}1011public function applyInternalEffects($object, $value) {12$object->setName($value);13}1415public function getTitle() {16return pht(17'%s renamed this webhook from %s to %s.',18$this->renderAuthor(),19$this->renderOldValue(),20$this->renderNewValue());21}2223public function getTitleForFeed() {24return pht(25'%s renamed %s from %s to %s.',26$this->renderAuthor(),27$this->renderObject(),28$this->renderOldValue(),29$this->renderNewValue());30}3132public function validateTransactions($object, array $xactions) {33$errors = array();34$viewer = $this->getActor();3536if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {37$errors[] = $this->newRequiredError(38pht('Webhooks must have a name.'));39return $errors;40}4142$max_length = $object->getColumnMaximumByteLength('name');43foreach ($xactions as $xaction) {44$old_value = $this->generateOldValue($object);45$new_value = $xaction->getNewValue();4647$new_length = strlen($new_value);48if ($new_length > $max_length) {49$errors[] = $this->newInvalidError(50pht(51'Webhook names can be no longer than %s characters.',52new PhutilNumber($max_length)));53}54}5556return $errors;57}5859}606162