Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / xaction / PhabricatorRepositorySymbolSourcesTransaction.php
blob781fad9d993a34b651cde877b93f6b8e2f4aae9e
1 <?php
3 final class PhabricatorRepositorySymbolSourcesTransaction
4 extends PhabricatorRepositoryTransactionType {
6 const TRANSACTIONTYPE = 'repo:symbol-source';
8 public function generateOldValue($object) {
9 return $object->getSymbolSources();
12 public function applyInternalEffects($object, $value) {
13 $object->setDetail('symbol-sources', $value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 $new = $this->getNewValue();
20 if ($old) {
21 $display_old = $this->renderHandleList($old);
22 } else {
23 $display_old = $this->renderValue(pht('None'));
26 if ($new) {
27 $display_new = $this->renderHandleList($new);
28 } else {
29 $display_new = $this->renderValue(pht('None'));
32 return pht(
33 '%s changed symbol sources from %s to %s.',
34 $this->renderAuthor(),
35 $display_old,
36 $display_new);
39 public function validateTransactions($object, array $xactions) {
40 $errors = array();
42 foreach ($xactions as $xaction) {
43 $old = $object->getSymbolSources();
44 $new = $xaction->getNewValue();
46 // If the viewer is adding new repositories, make sure they are
47 // valid and visible.
48 $add = array_diff($new, $old);
49 if (!$add) {
50 continue;
53 $repositories = id(new PhabricatorRepositoryQuery())
54 ->setViewer($this->getActor())
55 ->withPHIDs($add)
56 ->execute();
57 $repositories = mpull($repositories, null, 'getPHID');
59 foreach ($add as $phid) {
60 if (isset($repositories[$phid])) {
61 continue;
64 $errors[] = $this->newInvalidError(
65 pht(
66 'Repository ("%s") does not exist, or you do not have '.
67 'permission to see it.',
68 $phid),
69 $xaction);
70 break;
74 return $errors;