3 final class PhamePostTitleTransaction
4 extends PhamePostTransactionType
{
6 const TRANSACTIONTYPE
= 'phame.post.title';
8 public function generateOldValue($object) {
9 return $object->getTitle();
12 public function applyInternalEffects($object, $value) {
13 $object->setTitle($value);
16 public function getTitle() {
18 '%s renamed this blog post from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
24 public function getTitleForFeed() {
26 '%s renamed %s blog post from %s to %s.',
27 $this->renderAuthor(),
28 $this->renderObject(),
29 $this->renderOldValue(),
30 $this->renderNewValue());
33 public function validateTransactions($object, array $xactions) {
36 if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {
37 $errors[] = $this->newRequiredError(
38 pht('Posts must have a title.'));
41 $max_length = $object->getColumnMaximumByteLength('title');
42 foreach ($xactions as $xaction) {
43 $new_value = $xaction->getNewValue();
44 $new_length = strlen($new_value);
45 if ($new_length > $max_length) {
46 $errors[] = $this->newInvalidError(
47 pht('The title can be no longer than %s characters.',
48 new PhutilNumber($max_length)));