Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / storage / PhabricatorRepositoryURITransaction.php
blob241a95dad99a27639a9d177abb509b8c8a3aa538
1 <?php
3 final class PhabricatorRepositoryURITransaction
4 extends PhabricatorApplicationTransaction {
6 const TYPE_REPOSITORY = 'diffusion.uri.repository';
7 const TYPE_URI = 'diffusion.uri.uri';
8 const TYPE_IO = 'diffusion.uri.io';
9 const TYPE_DISPLAY = 'diffusion.uri.display';
10 const TYPE_CREDENTIAL = 'diffusion.uri.credential';
11 const TYPE_DISABLE = 'diffusion.uri.disable';
13 public function getApplicationName() {
14 return 'repository';
17 public function getApplicationTransactionType() {
18 return PhabricatorRepositoryURIPHIDType::TYPECONST;
21 public function getRequiredHandlePHIDs() {
22 $phids = parent::getRequiredHandlePHIDs();
24 $old = $this->getOldValue();
25 $new = $this->getNewValue();
27 switch ($this->getTransactionType()) {
28 case self::TYPE_CREDENTIAL:
29 if ($old) {
30 $phids[] = $old;
32 if ($new) {
33 $phids[] = $new;
35 break;
38 return $phids;
41 public function getTitle() {
42 $author_phid = $this->getAuthorPHID();
44 $old = $this->getOldValue();
45 $new = $this->getNewValue();
47 switch ($this->getTransactionType()) {
48 case self::TYPE_URI:
49 return pht(
50 '%s changed this URI from "%s" to "%s".',
51 $this->renderHandleLink($author_phid),
52 $old,
53 $new);
54 case self::TYPE_IO:
55 $map = PhabricatorRepositoryURI::getIOTypeMap();
56 $old_label = idx(idx($map, $old, array()), 'label', $old);
57 $new_label = idx(idx($map, $new, array()), 'label', $new);
59 return pht(
60 '%s changed the display type for this URI from "%s" to "%s".',
61 $this->renderHandleLink($author_phid),
62 $old_label,
63 $new_label);
64 case self::TYPE_DISPLAY:
65 $map = PhabricatorRepositoryURI::getDisplayTypeMap();
66 $old_label = idx(idx($map, $old, array()), 'label', $old);
67 $new_label = idx(idx($map, $new, array()), 'label', $new);
69 return pht(
70 '%s changed the display type for this URI from "%s" to "%s".',
71 $this->renderHandleLink($author_phid),
72 $old_label,
73 $new_label);
74 case self::TYPE_DISABLE:
75 if ($new) {
76 return pht(
77 '%s disabled this URI.',
78 $this->renderHandleLink($author_phid));
79 } else {
80 return pht(
81 '%s enabled this URI.',
82 $this->renderHandleLink($author_phid));
84 case self::TYPE_CREDENTIAL:
85 if ($old && $new) {
86 return pht(
87 '%s changed the credential for this URI from %s to %s.',
88 $this->renderHandleLink($author_phid),
89 $this->renderHandleLink($old),
90 $this->renderHandleLink($new));
91 } else if ($old) {
92 return pht(
93 '%s removed %s as the credential for this URI.',
94 $this->renderHandleLink($author_phid),
95 $this->renderHandleLink($old));
96 } else if ($new) {
97 return pht(
98 '%s set the credential for this URI to %s.',
99 $this->renderHandleLink($author_phid),
100 $this->renderHandleLink($new));
105 return parent::getTitle();