revisionID = $data['id'];
$this->strategyClass = $data['strategy'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$revision_id = $this->revisionID;
$revision = id(new DifferentialRevisionQuery())
->withIDs(array($revision_id))
->setViewer($viewer)
->executeOne();
if (!$revision) {
return new Aphront404Response();
}
if (is_subclass_of($this->strategyClass, 'DifferentialLandingStrategy')) {
$this->pushStrategy = newv($this->strategyClass, array());
} else {
throw new Exception(
"Strategy type must be a valid class name and must subclass ".
"DifferentialLandingStrategy. ".
"'{$this->strategyClass}' is not a subclass of ".
"DifferentialLandingStrategy.");
}
if ($request->isDialogFormPost()) {
$response = null;
$text = '';
try {
$response = $this->attemptLand($revision, $request);
$title = pht('Success!');
$text = pht('Revision was successfully landed.');
} catch (Exception $ex) {
$title = pht('Failed to land revision');
if ($ex instanceof PhutilProxyException) {
$text = hsprintf(
'%s:
%s', $ex->getMessage(), $ex->getPreviousException()->getMessage()); } else { $text = phutil_tag('pre', array(), $ex->getMessage()); } $text = id(new AphrontErrorView()) ->appendChild($text); } if ($response instanceof AphrontDialogView) { $dialog = $response; } else { $dialog = id(new AphrontDialogView()) ->setUser($viewer) ->setTitle($title) ->appendChild(phutil_tag('p', array(), $text)) ->addCancelButton('/D'.$revision_id, pht('Done')); } return id(new AphrontDialogResponse())->setDialog($dialog); } $is_disabled = $this->pushStrategy->isActionDisabled( $viewer, $revision, $revision->getRepository()); if ($is_disabled) { if (is_string($is_disabled)) { $explain = $is_disabled; } else { $explain = pht('This action is not currently enabled.'); } $dialog = id(new AphrontDialogView()) ->setUser($viewer) ->setTitle(pht("Can't land revision")) ->appendChild($explain) ->addCancelButton('/D'.$revision_id); return id(new AphrontDialogResponse())->setDialog($dialog); } $prompt = hsprintf('%s