Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / harbormaster / management / HarbormasterManagementPublishWorkflow.php
blobfecce6136e5c1aa85f52cbda16b33233db16deb3
1 <?php
3 final class HarbormasterManagementPublishWorkflow
4 extends HarbormasterManagementWorkflow {
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,
20 ));
23 public function execute(PhutilArgumentParser $args) {
24 $viewer = $this->getViewer();
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".'));
33 $query = id(new PhabricatorObjectQuery())
34 ->setViewer($viewer)
35 ->withNames($buildable_names);
37 $query->execute();
39 $result_map = $query->getNamedResults();
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));
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)));
62 foreach ($result_map as $buildable) {
63 echo tsprintf(
64 "%s\n",
65 pht(
66 'Publishing "%s"...',
67 $buildable->getMonogram()));
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();
76 $engine = id(new HarbormasterBuildEngine())
77 ->setViewer($viewer)
78 ->publishBuildable($buildable, $buildable);
81 echo tsprintf(
82 "%s\n",
83 pht('Done.'));
85 return 0;