Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/management/DrydockManagementUpdateResourceWorkflow.php
12256 views
1
<?php
2
3
final class DrydockManagementUpdateResourceWorkflow
4
extends DrydockManagementWorkflow {
5
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.'),
17
),
18
));
19
}
20
21
public function execute(PhutilArgumentParser $args) {
22
$viewer = $this->getViewer();
23
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'));
30
}
31
32
$resources = id(new DrydockResourceQuery())
33
->setViewer($viewer)
34
->withIDs($ids)
35
->execute();
36
37
PhabricatorWorker::setRunAllTasksInProcess(true);
38
39
foreach ($ids as $id) {
40
$resource = idx($resources, $id);
41
42
if (!$resource) {
43
echo tsprintf(
44
"%s\n",
45
pht('Resource "%s" does not exist.', $id));
46
continue;
47
}
48
49
echo tsprintf(
50
"%s\n",
51
pht('Updating resource "%s".', $id));
52
53
$resource->scheduleUpdate();
54
}
55
56
}
57
58
}
59
60