Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / herald / HarbormasterRunBuildPlansHeraldAction.php
blob6934a2e3d9a9f6f57a4e67b4abbd6340fdc3689c
1 <?php
3 final class HarbormasterRunBuildPlansHeraldAction
4 extends HeraldAction {
6 const DO_BUILD = 'do.build';
8 const ACTIONCONST = 'harbormaster.build';
10 public function getRequiredAdapterStates() {
11 return array(
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());
33 if (!$targets) {
34 return;
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() {
50 return array(
51 self::DO_BUILD => array(
52 'icon' => 'fa-play',
53 'color' => 'green',
54 'name' => pht('Building'),
59 protected function renderActionEffectDescription($type, $data) {
60 switch ($type) {
61 case self::DO_BUILD:
62 return pht(
63 'Started %s build(s): %s.',
64 phutil_count($data),
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) {
90 return pht(
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();