Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / drydock / management / DrydockManagementUpdateResourceWorkflow.php
blob79928fda8d6b21c52c78056606dbca7a9f2e53f4
1 <?php
3 final class DrydockManagementUpdateResourceWorkflow
4 extends DrydockManagementWorkflow {
6 protected function didConstruct() {
7 $this
8 ->setName('update-resource')
9 ->setSynopsis(pht('Update a resource.'))
10 ->setArguments(
11 array(
12 array(
13 'name' => 'id',
14 'param' => 'id',
15 'repeat' => true,
16 'help' => pht('Resource ID to update.'),
18 ));
21 public function execute(PhutilArgumentParser $args) {
22 $viewer = $this->getViewer();
24 $ids = $args->getArg('id');
25 if (!$ids) {
26 throw new PhutilArgumentUsageException(
27 pht(
28 'Specify one or more resource IDs to update with "%s".',
29 '--id'));
32 $resources = id(new DrydockResourceQuery())
33 ->setViewer($viewer)
34 ->withIDs($ids)
35 ->execute();
37 PhabricatorWorker::setRunAllTasksInProcess(true);
39 foreach ($ids as $id) {
40 $resource = idx($resources, $id);
42 if (!$resource) {
43 echo tsprintf(
44 "%s\n",
45 pht('Resource "%s" does not exist.', $id));
46 continue;
49 echo tsprintf(
50 "%s\n",
51 pht('Updating resource "%s".', $id));
53 $resource->scheduleUpdate();