[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DrydockResourceCloseController extends DrydockResourceController { 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 $resource = id(new DrydockResourceQuery()) 16 ->setViewer($viewer) 17 ->withIDs(array($this->id)) 18 ->executeOne(); 19 if (!$resource) { 20 return new Aphront404Response(); 21 } 22 23 $resource_uri = '/resource/'.$resource->getID().'/'; 24 $resource_uri = $this->getApplicationURI($resource_uri); 25 26 if ($resource->getStatus() != DrydockResourceStatus::STATUS_OPEN) { 27 $dialog = id(new AphrontDialogView()) 28 ->setUser($viewer) 29 ->setTitle(pht('Resource Not Open')) 30 ->appendChild(phutil_tag('p', array(), pht( 31 'You can only close "open" resources.'))) 32 ->addCancelButton($resource_uri); 33 34 return id(new AphrontDialogResponse())->setDialog($dialog); 35 } 36 37 if ($request->isFormPost()) { 38 $resource->closeResource(); 39 return id(new AphrontReloadResponse())->setURI($resource_uri); 40 } 41 42 $dialog = id(new AphrontDialogView()) 43 ->setUser($viewer) 44 ->setTitle(pht('Really close resource?')) 45 ->appendChild( 46 pht( 47 'Closing a resource releases all leases and destroys the '. 48 'resource. It can not be undone. Continue?')) 49 ->addSubmitButton(pht('Close Resource')) 50 ->addCancelButton($resource_uri); 51 52 return id(new AphrontDialogResponse())->setDialog($dialog); 53 } 54 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |