Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phame / xaction / PhameBlogParentSiteTransaction.php
blob1b62b984889064edc4563faa926b9c86ecb5a150
1 <?php
3 final class PhameBlogParentSiteTransaction
4 extends PhameBlogTransactionType {
6 const TRANSACTIONTYPE = 'phame.blog.parent.site';
8 public function generateOldValue($object) {
9 return $object->getParentSite();
12 public function applyInternalEffects($object, $value) {
13 $object->setParentSite($value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 if (!strlen($old)) {
19 return pht(
20 '%s set this blog\'s parent site to %s.',
21 $this->renderAuthor(),
22 $this->renderNewValue());
23 } else {
24 return pht(
25 '%s updated the blog\'s parent site from %s to %s.',
26 $this->renderAuthor(),
27 $this->renderOldValue(),
28 $this->renderNewValue());
32 public function getTitleForFeed() {
33 $old = $this->getOldValue();
34 if (!strlen($old)) {
35 return pht(
36 '%s set %s blog\'s parent site to %s.',
37 $this->renderAuthor(),
38 $this->renderObject(),
39 $this->renderNewValue());
40 } else {
41 return pht(
42 '%s updated %s blog\'s parent site from %s to %s.',
43 $this->renderAuthor(),
44 $this->renderObject(),
45 $this->renderOldValue(),
46 $this->renderNewValue());
50 public function validateTransactions($object, array $xactions) {
51 $errors = array();
53 $max_length = $object->getColumnMaximumByteLength('parentSite');
54 foreach ($xactions as $xaction) {
55 $new_value = $xaction->getNewValue();
56 $new_length = strlen($new_value);
57 if ($new_length > $max_length) {
58 $errors[] = $this->newInvalidError(
59 pht('The parent site can be no longer than %s characters.',
60 new PhutilNumber($max_length)));
64 return $errors;