Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / xaction / PhabricatorRepositoryTouchLimitTransaction.php
blobe3052d08948109b988d5a39d18e87009aa489ee5
1 <?php
3 final class PhabricatorRepositoryTouchLimitTransaction
4 extends PhabricatorRepositoryTransactionType {
6 const TRANSACTIONTYPE = 'limit.touch';
8 public function generateOldValue($object) {
9 return $object->getTouchLimit();
12 public function generateNewValue($object, $value) {
13 if (!strlen($value)) {
14 return null;
17 $value = (int)$value;
18 if (!$value) {
19 return null;
22 return $value;
25 public function applyInternalEffects($object, $value) {
26 $object->setTouchLimit($value);
29 public function getTitle() {
30 $old = $this->getOldValue();
31 $new = $this->getNewValue();
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());
53 public function validateTransactions($object, array $xactions) {
54 $errors = array();
56 foreach ($xactions as $xaction) {
57 $new = $xaction->getNewValue();
59 if (!strlen($new)) {
60 continue;
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;
73 return $errors;