Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / xaction / PhabricatorRepositoryServiceTransaction.php
blobf6d89a61f5c7668cad73af6a128ef066617c0bde
1 <?php
3 final class PhabricatorRepositoryServiceTransaction
4 extends PhabricatorRepositoryTransactionType {
6 const TRANSACTIONTYPE = 'repo:service';
8 public function generateOldValue($object) {
9 return $object->getAlmanacServicePHID();
12 public function generateNewValue($object, $value) {
13 if (strlen($value)) {
14 return $value;
17 return null;
20 public function applyInternalEffects($object, $value) {
21 $object->setAlmanacServicePHID($value);
24 public function getTitle() {
25 $old = $this->getOldValue();
26 $new = $this->getOldValue();
28 if (strlen($old) && !strlen($new)) {
29 return pht(
30 '%s moved storage for this repository from %s to local.',
31 $this->renderAuthor(),
32 $this->renderOldHandle());
33 } else if (!strlen($old) && strlen($new)) {
34 // TODO: Possibly, we should distinguish between automatic assignment
35 // on creation vs explicit adjustment.
36 return pht(
37 '%s set storage for this repository to %s.',
38 $this->renderAuthor(),
39 $this->renderNewHandle());
40 } else {
41 return pht(
42 '%s moved storage for this repository from %s to %s.',
43 $this->renderAuthor(),
44 $this->renderOldHandle(),
45 $this->renderNewHandle());
49 public function validateTransactions($object, array $xactions) {
50 $errors = array();
52 // TODO: This could use some validation, values should be valid Almanac
53 // services of appropriate types. It's only reachable via the CLI so it's
54 // difficult to get wrong in practice.
56 return $errors;