@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 89 lines 2.1 kB view raw
1<?php 2 3final class PholioMockNameTransaction 4 extends PholioMockTransactionType { 5 6 const TRANSACTIONTYPE = 'name'; 7 8 public function generateOldValue($object) { 9 return $object->getName(); 10 } 11 12 public function getActionStrength() { 13 return 140; 14 } 15 16 public function applyInternalEffects($object, $value) { 17 $object->setName($value); 18 } 19 20 public function getTitle() { 21 $old = $this->getOldValue(); 22 $new = $this->getNewValue(); 23 24 if ($old === null) { 25 return pht( 26 '%s created %s.', 27 $this->renderAuthor(), 28 $this->renderValue($new)); 29 } else { 30 return pht( 31 '%s renamed this mock from %s to %s.', 32 $this->renderAuthor(), 33 $this->renderValue($old), 34 $this->renderValue($new)); 35 } 36 } 37 38 public function getTitleForFeed() { 39 $old = $this->getOldValue(); 40 $new = $this->getNewValue(); 41 42 if ($old === null) { 43 return pht( 44 '%s created %s.', 45 $this->renderAuthor(), 46 $this->renderObject()); 47 } else { 48 return pht( 49 '%s renamed %s from %s to %s.', 50 $this->renderAuthor(), 51 $this->renderObject(), 52 $this->renderValue($old), 53 $this->renderValue($new)); 54 } 55 } 56 57 public function getColor() { 58 $old = $this->getOldValue(); 59 60 if ($old === null) { 61 return PhabricatorTransactions::COLOR_GREEN; 62 } 63 64 return parent::getColor(); 65 } 66 67 public function validateTransactions($object, array $xactions) { 68 $errors = array(); 69 70 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { 71 $errors[] = $this->newRequiredError(pht('Mocks must have a name.')); 72 } 73 74 $max_length = $object->getColumnMaximumByteLength('name'); 75 foreach ($xactions as $xaction) { 76 $new_value = $xaction->getNewValue(); 77 $new_length = strlen($new_value); 78 if ($new_length > $max_length) { 79 $errors[] = $this->newInvalidError( 80 pht( 81 'Mock names must not be longer than %s character(s).', 82 new PhutilNumber($max_length))); 83 } 84 } 85 86 return $errors; 87 } 88 89}