Path: blob/master/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
12256 views
<?php12final class DifferentialRevisionTitleTransaction3extends DifferentialRevisionTransactionType {45const TRANSACTIONTYPE = 'differential.revision.title';6const EDITKEY = 'title';78public function generateOldValue($object) {9return $object->getTitle();10}1112public function applyInternalEffects($object, $value) {13$object->setTitle($value);14}1516public function getTitle() {17return pht(18'%s retitled this revision from %s to %s.',19$this->renderAuthor(),20$this->renderOldValue(),21$this->renderNewValue());22}2324public function getTitleForFeed() {25return pht(26'%s retitled %s from %s to %s.',27$this->renderAuthor(),28$this->renderObject(),29$this->renderOldValue(),30$this->renderNewValue());31}3233public function validateTransactions($object, array $xactions) {34$errors = array();3536if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {37$errors[] = $this->newRequiredError(38pht('Revisions must have a title.'));39}4041$max_length = $object->getColumnMaximumByteLength('title');42foreach ($xactions as $xaction) {43$new_value = $xaction->getNewValue();44$new_length = strlen($new_value);45if ($new_length > $max_length) {46$errors[] = $this->newInvalidError(47pht(48'Revision title is too long: the maximum length of a '.49'revision title is 255 bytes.'),50$xaction);51}52}5354return $errors;55}5657public function getTransactionTypeForConduit($xaction) {58return 'title';59}6061public function getFieldValuesForConduit($xaction, $data) {62return array(63'old' => $xaction->getOldValue(),64'new' => $xaction->getNewValue(),65);66}6768}697071