Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / xaction / PhabricatorRepositoryCopyTimeLimitTransaction.php
blob6be3466ae79890c850c8b2a09b59ce44696060bd
1 <?php
3 final class PhabricatorRepositoryCopyTimeLimitTransaction
4 extends PhabricatorRepositoryTransactionType {
6 const TRANSACTIONTYPE = 'limit.copy';
8 public function generateOldValue($object) {
9 return $object->getCopyTimeLimit();
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->setCopyTimeLimit($value);
29 public function getTitle() {
30 $old = $this->getOldValue();
31 $new = $this->getNewValue();
33 if ($old && $new) {
34 return pht(
35 '%s changed the copy time limit for this repository from %s seconds '.
36 'to %s seconds.',
37 $this->renderAuthor(),
38 $this->renderOldValue(),
39 $this->renderNewValue());
40 } else if ($new) {
41 return pht(
42 '%s set the copy time limit for this repository to %s seconds.',
43 $this->renderAuthor(),
44 $this->renderNewValue());
45 } else {
46 return pht(
47 '%s reset the copy time limit (%s seconds) for this repository '.
48 'to the default value.',
49 $this->renderAuthor(),
50 $this->renderOldValue());
54 public function validateTransactions($object, array $xactions) {
55 $errors = array();
57 foreach ($xactions as $xaction) {
58 $new = $xaction->getNewValue();
60 if (!strlen($new)) {
61 continue;
64 if (!preg_match('/^\d+\z/', $new)) {
65 $errors[] = $this->newInvalidError(
66 pht(
67 'Unable to parse copy time limit, specify a positive number '.
68 'of seconds.'),
69 $xaction);
70 continue;
74 return $errors;