1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-11 16:16:14 +01:00
phorge-phorge/src/applications/transactions/controller/PhabricatorEditEngineConfigurationDisableController.php
Austin McKinley 6b9f4a918b Modularize PhabricatorEditEngineConfigurationTransaction
Summary: Ref T13319. Ref PHI1302. Migrate `PhabricatorEditEngineConfigurationTransaction` to modular transactions and add some additional transaction rendering to make these edits less opaque.

Test Plan: Hit all the form edit controllers, viewed resulting transaction timeline.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T13319

Differential Revision: https://secure.phabricator.com/D20595
2019-06-20 16:25:21 -07:00

59 lines
1.7 KiB
PHP

<?php
final class PhabricatorEditEngineConfigurationDisableController
extends PhabricatorEditEngineController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$config = $this->loadConfigForEdit();
if (!$config) {
return id(new Aphront404Response());
}
$engine_key = $config->getEngineKey();
$key = $config->getIdentifier();
$cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
$type = PhabricatorEditEngineDisableTransaction::TRANSACTIONTYPE;
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())
->setTransactionType($type)
->setNewValue(!$config->getIsDisabled());
$editor = id(new PhabricatorEditEngineConfigurationEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($config, $xactions);
return id(new AphrontRedirectResponse())
->setURI($cancel_uri);
}
if ($config->getIsDisabled()) {
$title = pht('Enable Form');
$body = pht(
'Enable this form? Users who can see it will be able to use it to '.
'create objects.');
$button = pht('Enable Form');
} else {
$title = pht('Disable Form');
$body = pht(
'Disable this form? Users will no longer be able to use it.');
$button = pht('Disable Form');
}
return $this->newDialog()
->setTitle($title)
->appendParagraph($body)
->addSubmitButton($button)
->addCancelbutton($cancel_uri);
}
}