Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / differential / xaction / DifferentialRevisionBuildableTransaction.php
blob3c4eaff729afe6d6fcbb156206924a215f583d9f
1 <?php
3 final class DifferentialRevisionBuildableTransaction
4 extends DifferentialRevisionTransactionType {
6 // NOTE: This uses an older constant for compatibility. We should perhaps
7 // migrate these at some point.
8 const TRANSACTIONTYPE = 'harbormaster:buildable';
10 public function generateNewValue($object, $value) {
11 return $value;
14 public function generateOldValue($object) {
15 return $object->getBuildableStatus($this->getBuildablePHID());
18 public function applyInternalEffects($object, $value) {
19 $object->setBuildableStatus($this->getBuildablePHID(), $value);
22 public function getIcon() {
23 return $this->newBuildableStatus()->getIcon();
26 public function getColor() {
27 return $this->newBuildableStatus()->getColor();
30 public function getActionName() {
31 return $this->newBuildableStatus()->getActionName();
34 public function shouldHideForFeed() {
35 return !$this->newBuildableStatus()->isFailed();
38 public function shouldHideForMail() {
39 return !$this->newBuildableStatus()->isFailed();
42 public function getTitle() {
43 $new = $this->getNewValue();
44 $buildable_phid = $this->getBuildablePHID();
46 switch ($new) {
47 case HarbormasterBuildableStatus::STATUS_PASSED:
48 return pht(
49 '%s completed remote builds in %s.',
50 $this->renderAuthor(),
51 $this->renderHandle($buildable_phid));
52 case HarbormasterBuildableStatus::STATUS_FAILED:
53 return pht(
54 '%s failed remote builds in %s!',
55 $this->renderAuthor(),
56 $this->renderHandle($buildable_phid));
59 return null;
62 public function getTitleForFeed() {
63 $new = $this->getNewValue();
64 $buildable_phid = $this->getBuildablePHID();
66 switch ($new) {
67 case HarbormasterBuildableStatus::STATUS_PASSED:
68 return pht(
69 '%s completed remote builds in %s for %s.',
70 $this->renderAuthor(),
71 $this->renderHandle($buildable_phid),
72 $this->renderObject());
73 case HarbormasterBuildableStatus::STATUS_FAILED:
74 return pht(
75 '%s failed remote builds in %s for %s!',
76 $this->renderAuthor(),
77 $this->renderHandle($buildable_phid),
78 $this->renderObject());
81 return null;
84 private function newBuildableStatus() {
85 $new = $this->getNewValue();
86 return HarbormasterBuildableStatus::newBuildableStatusObject($new);
89 private function getBuildablePHID() {
90 return $this->getMetadataValue('harbormaster:buildablePHID');