Differential D7751 Diff 17565 src/applications/phragment/controller/PhragmentSnapshotDeleteController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phragment/controller/PhragmentSnapshotDeleteController.php
<?php | <?php | ||||
final class PhragmentSnapshotDeleteController extends PhragmentController { | final class PhragmentSnapshotDeleteController extends PhragmentController { | ||||
private $id; | private $id; | ||||
public function willProcessRequest(array $data) { | public function willProcessRequest(array $data) { | ||||
$this->id = $data['id']; | $this->id = $data['id']; | ||||
} | } | ||||
public function processRequest() { | public function processRequest() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$snapshot = id(new PhragmentSnapshotQuery()) | $snapshot = id(new PhragmentSnapshotQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->requireCapabilities(array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT)) | |||||
->withIDs(array($this->id)) | ->withIDs(array($this->id)) | ||||
->executeOne(); | ->executeOne(); | ||||
if ($snapshot === null) { | if ($snapshot === null) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
if ($request->isDialogFormPost()) { | if ($request->isDialogFormPost()) { | ||||
epriestley: Do this in the query. | |||||
$fragment_uri = $snapshot->getPrimaryFragment()->getURI(); | $fragment_uri = $snapshot->getPrimaryFragment()->getURI(); | ||||
$snapshot->delete(); | $snapshot->delete(); | ||||
return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
->setURI($fragment_uri); | ->setURI($fragment_uri); | ||||
} | } | ||||
Show All 19 Lines |
Do this in the query.