3 final class PhabricatorPasteArchiveController
4 extends PhabricatorPasteController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $paste = id(new PhabricatorPasteQuery())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 $view_uri = $paste->getURI();
25 if ($request->isFormPost()) {
26 if ($paste->isArchived()) {
27 $new_status = PhabricatorPaste
::STATUS_ACTIVE
;
29 $new_status = PhabricatorPaste
::STATUS_ARCHIVED
;
34 $xactions[] = id(new PhabricatorPasteTransaction())
35 ->setTransactionType(PhabricatorPasteStatusTransaction
::TRANSACTIONTYPE
)
36 ->setNewValue($new_status);
38 id(new PhabricatorPasteEditor())
40 ->setContentSourceFromRequest($request)
41 ->setContinueOnNoEffect(true)
42 ->setContinueOnMissingFields(true)
43 ->applyTransactions($paste, $xactions);
45 return id(new AphrontRedirectResponse())->setURI($view_uri);
48 if ($paste->isArchived()) {
49 $title = pht('Activate Paste');
50 $body = pht('This paste will become consumable again.');
51 $button = pht('Activate Paste');
53 $title = pht('Archive Paste');
54 $body = pht('This paste will be marked as expired.');
55 $button = pht('Archive Paste');
58 return $this->newDialog()
61 ->addCancelButton($view_uri)
62 ->addSubmitButton($button);