[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DrydockManagementCloseWorkflow 4 extends DrydockManagementWorkflow { 5 6 public function didConstruct() { 7 $this 8 ->setName('close') 9 ->setSynopsis('Close a resource.') 10 ->setArguments( 11 array( 12 array( 13 'name' => 'ids', 14 'wildcard' => true, 15 ), 16 )); 17 } 18 19 public function execute(PhutilArgumentParser $args) { 20 $console = PhutilConsole::getConsole(); 21 22 $ids = $args->getArg('ids'); 23 if (!$ids) { 24 throw new PhutilArgumentUsageException( 25 'Specify one or more resource IDs to close.'); 26 } 27 28 $viewer = $this->getViewer(); 29 30 $resources = id(new DrydockResourceQuery()) 31 ->setViewer($viewer) 32 ->withIDs($ids) 33 ->execute(); 34 35 foreach ($ids as $id) { 36 $resource = idx($resources, $id); 37 if (!$resource) { 38 $console->writeErr("Resource %d does not exist!\n", $id); 39 } else if ($resource->getStatus() != DrydockResourceStatus::STATUS_OPEN) { 40 $console->writeErr("Resource %d is not 'open'!\n", $id); 41 } else { 42 $resource->closeResource(); 43 $console->writeErr("Closed resource %d.\n", $id); 44 } 45 } 46 47 } 48 49 }
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 |