Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / diffusion / controller / DiffusionRepositoryEditActivateController.php
blob7e2d06982d244af82df4a35bcbf98b08dd172485
1 <?php
3 final class DiffusionRepositoryEditActivateController
4 extends DiffusionRepositoryManageController {
6 public function handleRequest(AphrontRequest $request) {
7 $response = $this->loadDiffusionContextForEdit();
8 if ($response) {
9 return $response;
12 $viewer = $this->getViewer();
13 $drequest = $this->getDiffusionRequest();
14 $repository = $drequest->getRepository();
16 $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel())
17 ->setRepository($repository)
18 ->getPanelURI();
20 if ($request->isFormPost()) {
21 if (!$repository->isTracked()) {
22 $new_status = PhabricatorRepository::STATUS_ACTIVE;
23 } else {
24 $new_status = PhabricatorRepository::STATUS_INACTIVE;
27 $xaction = id(new PhabricatorRepositoryTransaction())
28 ->setTransactionType(
29 PhabricatorRepositoryActivateTransaction::TRANSACTIONTYPE)
30 ->setNewValue($new_status);
32 $editor = id(new PhabricatorRepositoryEditor())
33 ->setContinueOnNoEffect(true)
34 ->setContinueOnMissingFields(true)
35 ->setContentSourceFromRequest($request)
36 ->setActor($viewer)
37 ->applyTransactions($repository, array($xaction));
39 return id(new AphrontReloadResponse())->setURI($panel_uri);
42 if ($repository->isTracked()) {
43 $title = pht('Deactivate Repository');
44 $body = pht(
45 'If you deactivate this repository, it will no longer be updated. '.
46 'Observation and mirroring will cease, and pushing and pulling will '.
47 'be disabled. You can reactivate the repository later.');
48 $submit = pht('Deactivate Repository');
49 } else {
50 $title = pht('Activate Repository');
52 $is_new = $repository->isNewlyInitialized();
53 if ($is_new) {
54 if ($repository->isHosted()) {
55 $body = pht(
56 'This repository will become a new hosted repository. '.
57 'It will begin serving read and write traffic.');
58 } else {
59 $body = pht(
60 'This repository will observe an existing remote repository. '.
61 'It will begin fetching changes from the remote.');
63 } else {
64 $body = pht(
65 'This repository will resume updates, observation, mirroring, '.
66 'and serving any configured read and write traffic.');
69 $submit = pht('Activate Repository');
72 return $this->newDialog()
73 ->setTitle($title)
74 ->appendChild($body)
75 ->addSubmitButton($submit)
76 ->addCancelButton($panel_uri);