[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/harbormaster/controller/ -> HarbormasterStepDeleteController.php (source)

   1  <?php
   2  
   3  final class HarbormasterStepDeleteController extends HarbormasterController {
   4  
   5    private $id;
   6  
   7    public function willProcessRequest(array $data) {
   8      $this->id = $data['id'];
   9    }
  10  
  11    public function processRequest() {
  12      $request = $this->getRequest();
  13      $viewer = $request->getUser();
  14  
  15      $this->requireApplicationCapability(
  16        HarbormasterManagePlansCapability::CAPABILITY);
  17  
  18      $id = $this->id;
  19  
  20      $step = id(new HarbormasterBuildStepQuery())
  21        ->setViewer($viewer)
  22        ->withIDs(array($id))
  23        ->executeOne();
  24      if ($step === null) {
  25        throw new Exception('Build step not found!');
  26      }
  27  
  28      $plan_id = $step->getBuildPlan()->getID();
  29      $done_uri = $this->getApplicationURI('plan/'.$plan_id.'/');
  30  
  31      if ($request->isDialogFormPost()) {
  32        $step->delete();
  33        return id(new AphrontRedirectResponse())->setURI($done_uri);
  34      }
  35  
  36      $dialog = new AphrontDialogView();
  37      $dialog->setTitle(pht('Really Delete Step?'))
  38              ->setUser($viewer)
  39              ->addSubmitButton(pht('Delete Build Step'))
  40              ->addCancelButton($done_uri);
  41      $dialog->appendChild(
  42        phutil_tag(
  43          'p',
  44          array(),
  45          pht(
  46            'Are you sure you want to delete this '.
  47            'step? This can\'t be undone!')));
  48      return id(new AphrontDialogResponse())->setDialog($dialog);
  49    }
  50  
  51  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1