Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phame / xaction / PhameBlogParentDomainTransaction.php
blob227c8ce8c3df49d8165a70d83a225eeef0c1ad7e
1 <?php
3 final class PhameBlogParentDomainTransaction
4 extends PhameBlogTransactionType {
6 const TRANSACTIONTYPE = 'phame.blog.parent.domain';
8 public function generateOldValue($object) {
9 return $object->getParentDomain();
12 public function applyInternalEffects($object, $value) {
13 $object->setParentDomain($value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 if (!strlen($old)) {
19 return pht(
20 '%s set this blog\'s parent domain to %s.',
21 $this->renderAuthor(),
22 $this->renderNewValue());
23 } else {
24 return pht(
25 '%s updated the blog\'s parent domain 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 domain to %s.',
37 $this->renderAuthor(),
38 $this->renderObject(),
39 $this->renderNewValue());
40 } else {
41 return pht(
42 '%s updated %s blog\'s parent domain 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 if (!$xactions) {
54 return $errors;
57 $parent_domain = last($xactions)->getNewValue();
58 if (empty($parent_domain)) {
59 return $errors;
62 try {
63 PhabricatorEnv::requireValidRemoteURIForLink($parent_domain);
64 } catch (Exception $ex) {
65 $errors[] = $this->newInvalidError(
66 pht('Parent Domain must be set to a valid Remote URI.'));
69 $max_length = $object->getColumnMaximumByteLength('parentDomain');
70 foreach ($xactions as $xaction) {
71 $new_value = $xaction->getNewValue();
72 $new_length = strlen($new_value);
73 if ($new_length > $max_length) {
74 $errors[] = $this->newInvalidError(
75 pht('The parent domain can be no longer than %s characters.',
76 new PhutilNumber($max_length)));
80 return $errors;