@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 76 lines 1.7 kB view raw
1<?php 2 3final class PhabricatorRepositoryTouchLimitTransaction 4 extends PhabricatorRepositoryTransactionType { 5 6 const TRANSACTIONTYPE = 'limit.touch'; 7 8 public function generateOldValue($object) { 9 return $object->getTouchLimit(); 10 } 11 12 public function generateNewValue($object, $value) { 13 if (!strlen($value)) { 14 return null; 15 } 16 17 $value = (int)$value; 18 if (!$value) { 19 return null; 20 } 21 22 return $value; 23 } 24 25 public function applyInternalEffects($object, $value) { 26 $object->setTouchLimit($value); 27 } 28 29 public function getTitle() { 30 $old = $this->getOldValue(); 31 $new = $this->getNewValue(); 32 33 if ($old && $new) { 34 return pht( 35 '%s changed the touch limit for this repository from %s paths to '. 36 '%s paths.', 37 $this->renderAuthor(), 38 $this->renderOldValue(), 39 $this->renderNewValue()); 40 } else if ($new) { 41 return pht( 42 '%s set the touch limit for this repository to %s paths.', 43 $this->renderAuthor(), 44 $this->renderNewValue()); 45 } else { 46 return pht( 47 '%s removed the touch limit (%s paths) for this repository.', 48 $this->renderAuthor(), 49 $this->renderOldValue()); 50 } 51 } 52 53 public function validateTransactions($object, array $xactions) { 54 $errors = array(); 55 56 foreach ($xactions as $xaction) { 57 $new = $xaction->getNewValue(); 58 59 if (!strlen($new)) { 60 continue; 61 } 62 63 if (!preg_match('/^\d+\z/', $new)) { 64 $errors[] = $this->newInvalidError( 65 pht( 66 'Unable to parse touch limit, specify a positive number of '. 67 'paths.'), 68 $xaction); 69 continue; 70 } 71 } 72 73 return $errors; 74 } 75 76}