Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/management/HarbormasterManagementPublishWorkflow.php
12256 views
1
<?php
2
3
final class HarbormasterManagementPublishWorkflow
4
extends HarbormasterManagementWorkflow {
5
6
protected function didConstruct() {
7
$this
8
->setName('publish')
9
->setExamples(pht('**publish** __buildable__ ...'))
10
->setSynopsis(
11
pht(
12
'Publish a buildable. This is primarily useful for developing '.
13
'and debugging applications which have buildable objects.'))
14
->setArguments(
15
array(
16
array(
17
'name' => 'buildable',
18
'wildcard' => true,
19
),
20
));
21
}
22
23
public function execute(PhutilArgumentParser $args) {
24
$viewer = $this->getViewer();
25
26
$buildable_names = $args->getArg('buildable');
27
if (!$buildable_names) {
28
throw new PhutilArgumentUsageException(
29
pht(
30
'Name one or more buildables to publish, like "B123".'));
31
}
32
33
$query = id(new PhabricatorObjectQuery())
34
->setViewer($viewer)
35
->withNames($buildable_names);
36
37
$query->execute();
38
39
$result_map = $query->getNamedResults();
40
41
foreach ($buildable_names as $name) {
42
if (!isset($result_map[$name])) {
43
throw new PhutilArgumentUsageException(
44
pht(
45
'Argument "%s" does not name a buildable. Provide one or more '.
46
'valid buildable monograms or PHIDs.',
47
$name));
48
}
49
}
50
51
foreach ($result_map as $name => $result) {
52
if (!($result instanceof HarbormasterBuildable)) {
53
throw new PhutilArgumentUsageException(
54
pht(
55
'Object "%s" is not a HarbormasterBuildable (it is a "%s"). '.
56
'Name one or more buildables to publish, like "B123".',
57
$name,
58
get_class($result)));
59
}
60
}
61
62
foreach ($result_map as $buildable) {
63
echo tsprintf(
64
"%s\n",
65
pht(
66
'Publishing "%s"...',
67
$buildable->getMonogram()));
68
69
// Reload the buildable to pick up builds.
70
$buildable = id(new HarbormasterBuildableQuery())
71
->setViewer($viewer)
72
->withIDs(array($buildable->getID()))
73
->needBuilds(true)
74
->executeOne();
75
76
$engine = id(new HarbormasterBuildEngine())
77
->setViewer($viewer)
78
->publishBuildable($buildable, $buildable);
79
}
80
81
echo tsprintf(
82
"%s\n",
83
pht('Done.'));
84
85
return 0;
86
}
87
88
}
89
90