Remove product literal strings in "pht()", part 8
[phabricator.git] / src / applications / pholio / xaction / PholioMockNameTransaction.php
blobaae0523f3225a35445b292fc1c070afdb8d4359d
1 <?php
3 final class PholioMockNameTransaction
4 extends PholioMockTransactionType {
6 const TRANSACTIONTYPE = 'name';
8 public function generateOldValue($object) {
9 return $object->getName();
12 public function getActionStrength() {
13 return 140;
16 public function applyInternalEffects($object, $value) {
17 $object->setName($value);
20 public function getTitle() {
21 $old = $this->getOldValue();
22 $new = $this->getNewValue();
24 if ($old === null) {
25 return pht(
26 '%s created %s.',
27 $this->renderAuthor(),
28 $this->renderValue($new));
29 } else {
30 return pht(
31 '%s renamed this mock from %s to %s.',
32 $this->renderAuthor(),
33 $this->renderValue($old),
34 $this->renderValue($new));
38 public function getTitleForFeed() {
39 $old = $this->getOldValue();
40 $new = $this->getNewValue();
42 if ($old === null) {
43 return pht(
44 '%s created %s.',
45 $this->renderAuthor(),
46 $this->renderObject());
47 } else {
48 return pht(
49 '%s renamed %s from %s to %s.',
50 $this->renderAuthor(),
51 $this->renderObject(),
52 $this->renderValue($old),
53 $this->renderValue($new));
57 public function getColor() {
58 $old = $this->getOldValue();
60 if ($old === null) {
61 return PhabricatorTransactions::COLOR_GREEN;
64 return parent::getColor();
67 public function validateTransactions($object, array $xactions) {
68 $errors = array();
70 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
71 $errors[] = $this->newRequiredError(pht('Mocks must have a name.'));
74 $max_length = $object->getColumnMaximumByteLength('name');
75 foreach ($xactions as $xaction) {
76 $new_value = $xaction->getNewValue();
77 $new_length = strlen($new_value);
78 if ($new_length > $max_length) {
79 $errors[] = $this->newInvalidError(
80 pht(
81 'Mock names must not be longer than %s character(s).',
82 new PhutilNumber($max_length)));
86 return $errors;