3 final class HarbormasterRunBuildPlansHeraldAction
6 const DO_BUILD
= 'do.build';
8 const ACTIONCONST
= 'harbormaster.build';
10 public function getRequiredAdapterStates() {
12 HeraldBuildableState
::STATECONST
,
16 public function getActionGroupKey() {
17 return HeraldSupportActionGroup
::ACTIONGROUPKEY
;
20 public function supportsObject($object) {
21 $adapter = $this->getAdapter();
22 return ($adapter instanceof HarbormasterBuildableAdapterInterface
);
25 protected function applyBuilds(array $phids, HeraldRule
$rule) {
26 $adapter = $this->getAdapter();
28 $allowed_types = array(
29 HarbormasterBuildPlanPHIDType
::TYPECONST
,
32 $targets = $this->loadStandardTargets($phids, $allowed_types, array());
37 $phids = array_fuse(array_keys($targets));
39 foreach ($phids as $phid) {
40 $request = id(new HarbormasterBuildRequest())
41 ->setBuildPlanPHID($phid)
42 ->setInitiatorPHID($rule->getPHID());
43 $adapter->queueHarbormasterBuildRequest($request);
46 $this->logEffect(self
::DO_BUILD
, $phids);
49 protected function getActionEffectMap() {
51 self
::DO_BUILD
=> array(
54 'name' => pht('Building'),
59 protected function renderActionEffectDescription($type, $data) {
63 'Started %s build(s): %s.',
65 $this->renderHandleList($data));
69 public function getHeraldActionName() {
70 return pht('Run build plans');
73 public function supportsRuleType($rule_type) {
74 return ($rule_type != HeraldRuleTypeConfig
::RULE_TYPE_PERSONAL
);
77 public function applyEffect($object, HeraldEffect
$effect) {
78 return $this->applyBuilds($effect->getTarget(), $effect->getRule());
81 public function getHeraldActionStandardType() {
82 return self
::STANDARD_PHID_LIST
;
85 protected function getDatasource() {
86 return new HarbormasterBuildPlanDatasource();
89 public function renderActionDescription($value) {
91 'Run build plans: %s.',
92 $this->renderHandleList($value));
95 public function getPHIDsAffectedByAction(HeraldActionRecord
$record) {
96 return $record->getTarget();
99 public function isActionAvailable() {
100 return id(new PhabricatorHarbormasterApplication())->isInstalled();