Differential D16572 Diff 39890 src/applications/differential/controller/DifferentialRevisionLandController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/controller/DifferentialRevisionLandController.php
<?php | <?php | ||||
final class DifferentialRevisionLandController extends DifferentialController { | final class DifferentialRevisionLandController extends DifferentialController { | ||||
private $revisionID; | |||||
private $strategyClass; | |||||
private $pushStrategy; | private $pushStrategy; | ||||
public function willProcessRequest(array $data) { | |||||
$this->revisionID = $data['id']; | |||||
$this->strategyClass = $data['strategy']; | |||||
} | |||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$revision_id = $request->getURIData('id'); | |||||
$revision_id = $this->revisionID; | $strategy_class = $request->getURIData('strategy'); | ||||
$revision = id(new DifferentialRevisionQuery()) | $revision = id(new DifferentialRevisionQuery()) | ||||
->withIDs(array($revision_id)) | ->withIDs(array($revision_id)) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$revision) { | if (!$revision) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
if (is_subclass_of($this->strategyClass, 'DifferentialLandingStrategy')) { | if (is_subclass_of($strategy_class, 'DifferentialLandingStrategy')) { | ||||
$this->pushStrategy = newv($this->strategyClass, array()); | $this->pushStrategy = newv($strategy_class, array()); | ||||
} else { | } else { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
"Strategy type must be a valid class name and must subclass ". | "Strategy type must be a valid class name and must subclass ". | ||||
"%s. '%s' is not a subclass of %s", | "%s. '%s' is not a subclass of %s", | ||||
'DifferentialLandingStrategy', | 'DifferentialLandingStrategy', | ||||
$this->strategyClass, | $strategy_class, | ||||
'DifferentialLandingStrategy')); | 'DifferentialLandingStrategy')); | ||||
} | } | ||||
if ($request->isDialogFormPost()) { | if ($request->isDialogFormPost()) { | ||||
$response = null; | $response = null; | ||||
$text = ''; | $text = ''; | ||||
try { | try { | ||||
$response = $this->attemptLand($revision, $request); | $response = $this->attemptLand($revision, $request); | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |