3 final class PholioMockNameTransaction
4 extends PholioMockTransactionType
{
6 const TRANSACTIONTYPE
= 'name';
8 public function generateOldValue($object) {
9 return $object->getName();
12 public function getActionStrength() {
16 public function applyInternalEffects($object, $value) {
17 $object->setName($value);
20 public function getTitle() {
21 $old = $this->getOldValue();
22 $new = $this->getNewValue();
27 $this->renderAuthor(),
28 $this->renderValue($new));
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();
45 $this->renderAuthor(),
46 $this->renderObject());
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();
61 return PhabricatorTransactions
::COLOR_GREEN
;
64 return parent
::getColor();
67 public function validateTransactions($object, array $xactions) {
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(
81 'Mock names must not be longer than %s character(s).',
82 new PhutilNumber($max_length)));