Differential D17402 Diff 41846 src/applications/badges/xaction/PhabricatorBadgesBadgeQualityTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/badges/xaction/PhabricatorBadgesBadgeQualityTransaction.php
- This file was added.
<?php | |||||
final class PhabricatorBadgesBadgeQualityTransaction | |||||
extends PhabricatorBadgesBadgeTransactionType { | |||||
const TRANSACTIONTYPE = 'badge.quality'; | |||||
public function generateOldValue($object) { | |||||
return $object->getQuality(); | |||||
} | |||||
public function applyInternalEffects($object, $value) { | |||||
$object->setQuality($value); | |||||
} | |||||
public function shouldHide() { | |||||
if ($this->isCreateTransaction()) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
epriestley: As above, likely obsolete. | |||||
public function getTitle() { | |||||
$old = $this->getQualityLabel($this->getOldValue()); | |||||
$new = $this->getQualityLabel($this->getNewValue()); | |||||
return pht( | |||||
'%s updated the quality from %s to %s.', | |||||
$this->renderAuthor(), | |||||
$old, | |||||
$new); | |||||
} | |||||
public function getTitleForFeed() { | |||||
$old = $this->getQualityLabel($this->getOldValue()); | |||||
$new = $this->getQualityLabel($this->getNewValue()); | |||||
return pht( | |||||
'%s updated %s quality from %s to %s.', | |||||
$this->renderAuthor(), | |||||
$this->renderObject(), | |||||
$new, | |||||
$old); | |||||
epriestleyUnsubmitted Not Done Inline ActionsThese should maaaaaybe use renderValue(...) to pick up the italic style? ModularTransactions generally uses renderValue() for titles, etc. Not sure if we want to count this sort of text as user-provided text or not. epriestley: These should maaaaaybe use `renderValue(...)` to pick up the italic style? ModularTransactions… | |||||
chadAuthorUnsubmitted Not Done Inline ActionsI couldn't get that to work? The value is a number. chad: I couldn't get that to work? The value is a number. | |||||
epriestleyUnsubmitted Not Done Inline ActionsOh, sorry, I mean like this? Or did that not work either? $new = $this->getNewValue(); // Raw number, like 3. $new = $this->getQualityLabel($new); // Now a string, like "Rare". $new = $this->renderValue($new); // Now a fancy string, like //Rare//. epriestley: Oh, sorry, I mean like this? Or did that not work either?
```
$new = $this->getNewValue(); //… | |||||
} | |||||
public function validateTransactions($object, array $xactions) { | |||||
$errors = array(); | |||||
if ($this->isEmptyTextTransaction($object->getQuality(), $xactions)) { | |||||
$errors[] = $this->newRequiredError( | |||||
pht('Badge quality must be set.')); | |||||
} | |||||
$map = PhabricatorBadgesQuality::getQualityMap(); | |||||
if (!$map[$object->getQuality()]) { | |||||
$errors[] = $this->newRequiredError( | |||||
pht('Badge quality is not valid.')); | |||||
} | |||||
return $errors; | |||||
} | |||||
private function getQualityLabel($quality) { | |||||
$map = PhabricatorBadgesQuality::getQualityMap(); | |||||
return $map[$quality]['name']; | |||||
} | |||||
} |
As above, likely obsolete.