Path: blob/master/src/applications/maniphest/xaction/ManiphestTaskTitleTransaction.php
12256 views
<?php12final class ManiphestTaskTitleTransaction3extends ManiphestTaskTransactionType {45const TRANSACTIONTYPE = 'title';67public function generateOldValue($object) {8return $object->getTitle();9}1011public function applyInternalEffects($object, $value) {12$object->setTitle($value);13}1415public function getActionStrength() {16return 140;17}1819public function getActionName() {20$old = $this->getOldValue();2122if (!strlen($old)) {23return pht('Created');24}2526return pht('Retitled');27}2829public function getTitle() {30$old = $this->getOldValue();3132if (!strlen($old)) {33return pht(34'%s created this task.',35$this->renderAuthor());36}3738return pht(39'%s renamed this task from %s to %s.',40$this->renderAuthor(),41$this->renderOldValue(),42$this->renderNewValue());4344}4546public function getTitleForFeed() {47$old = $this->getOldValue();48if ($old === null) {49return pht(50'%s created %s.',51$this->renderAuthor(),52$this->renderObject());53}5455return pht(56'%s renamed %s from %s to %s.',57$this->renderAuthor(),58$this->renderObject(),59$this->renderOldValue(),60$this->renderNewValue());61}6263public function validateTransactions($object, array $xactions) {64$errors = array();6566// If the user is acting via "Bulk Edit" or another workflow which67// continues on missing fields, they may be applying a transaction which68// removes the task title. Mark these transactions as invalid first,69// then flag the missing field error if we don't find any more specific70// problems.7172foreach ($xactions as $xaction) {73$new = $xaction->getNewValue();74if (!strlen($new)) {75$errors[] = $this->newInvalidError(76pht('Tasks must have a title.'),77$xaction);78continue;79}80}8182if (!$errors) {83if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {84$errors[] = $this->newRequiredError(85pht('Tasks must have a title.'));86}87}8889return $errors;90}9192public function getTransactionTypeForConduit($xaction) {93return 'title';94}9596public function getFieldValuesForConduit($xaction, $data) {97return array(98'old' => $xaction->getOldValue(),99'new' => $xaction->getNewValue(),100);101}102103}104105106