Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/management/DrydockManagementUpdateLeaseWorkflow.php
12256 views
1
<?php
2
3
final class DrydockManagementUpdateLeaseWorkflow
4
extends DrydockManagementWorkflow {
5
6
protected function didConstruct() {
7
$this
8
->setName('update-lease')
9
->setSynopsis(pht('Update a lease.'))
10
->setArguments(
11
array(
12
array(
13
'name' => 'id',
14
'param' => 'id',
15
'repeat' => true,
16
'help' => pht('Lease 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 lease IDs to update with "%s".',
29
'--id'));
30
}
31
32
$leases = id(new DrydockLeaseQuery())
33
->setViewer($viewer)
34
->withIDs($ids)
35
->execute();
36
37
PhabricatorWorker::setRunAllTasksInProcess(true);
38
39
foreach ($ids as $id) {
40
$lease = idx($leases, $id);
41
42
if (!$lease) {
43
echo tsprintf(
44
"%s\n",
45
pht('Lease "%s" does not exist.', $id));
46
continue;
47
}
48
49
echo tsprintf(
50
"%s\n",
51
pht('Updating lease "%s".', $id));
52
53
$lease->scheduleUpdate();
54
}
55
}
56
57
}
58
59