@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 71 lines 1.6 kB view raw
1<?php 2 3/** 4 * Start a build. 5 */ 6final class HarbormasterBuildWorker extends HarbormasterWorker { 7 8 public function renderForDisplay(PhabricatorUser $viewer) { 9 try { 10 $build = $this->loadBuild(); 11 } catch (Exception $ex) { 12 return null; 13 } 14 15 return $viewer->renderHandle($build->getPHID()); 16 } 17 18 protected function doWork() { 19 $viewer = $this->getViewer(); 20 21 $engine = id(new HarbormasterBuildEngine()) 22 ->setViewer($viewer); 23 24 $data = $this->getTaskData(); 25 $build_id = idx($data, 'buildID'); 26 27 if ($build_id) { 28 $build = $this->loadBuild(); 29 $engine->setBuild($build); 30 $engine->continueBuild(); 31 } else { 32 $buildable = $this->loadBuildable(); 33 $engine->updateBuildable($buildable); 34 } 35 } 36 37 private function loadBuild() { 38 $data = $this->getTaskData(); 39 $id = idx($data, 'buildID'); 40 41 $viewer = $this->getViewer(); 42 $build = id(new HarbormasterBuildQuery()) 43 ->setViewer($viewer) 44 ->withIDs(array($id)) 45 ->executeOne(); 46 if (!$build) { 47 throw new PhabricatorWorkerPermanentFailureException( 48 pht('Invalid build ID "%s".', $id)); 49 } 50 51 return $build; 52 } 53 54 private function loadBuildable() { 55 $data = $this->getTaskData(); 56 $phid = idx($data, 'buildablePHID'); 57 58 $viewer = $this->getViewer(); 59 $buildable = id(new HarbormasterBuildableQuery()) 60 ->setViewer($viewer) 61 ->withPHIDs(array($phid)) 62 ->executeOne(); 63 if (!$buildable) { 64 throw new PhabricatorWorkerPermanentFailureException( 65 pht('Invalid buildable PHID "%s".', $phid)); 66 } 67 68 return $buildable; 69 } 70 71}