3 final class PhameBlogFullDomainTransaction
4 extends PhameBlogTransactionType
{
6 const TRANSACTIONTYPE
= 'phame.blog.full.domain';
8 public function generateOldValue($object) {
9 return $object->getDomainFullURI();
12 public function applyInternalEffects($object, $value) {
14 $uri = new PhutilURI($value);
15 $domain = $uri->getDomain();
16 $object->setDomain($domain);
18 $object->setDomain(null);
20 $object->setDomainFullURI($value);
23 public function getTitle() {
24 $old = $this->getOldValue();
27 '%s set this blog\'s full domain to %s.',
28 $this->renderAuthor(),
29 $this->renderNewValue());
32 '%s updated the blog\'s full domain from %s to %s.',
33 $this->renderAuthor(),
34 $this->renderOldValue(),
35 $this->renderNewValue());
39 public function getTitleForFeed() {
40 $old = $this->getOldValue();
43 '%s set %s blog\'s full domain to %s.',
44 $this->renderAuthor(),
45 $this->renderObject(),
46 $this->renderNewValue());
49 '%s updated %s blog\'s full domain from %s to %s.',
50 $this->renderAuthor(),
51 $this->renderObject(),
52 $this->renderOldValue(),
53 $this->renderNewValue());
57 public function validateTransactions($object, array $xactions) {
64 $custom_domain = last($xactions)->getNewValue();
65 if (empty($custom_domain)) {
69 $error_text = $object->validateCustomDomain($custom_domain);
71 $errors[] = $this->newInvalidError($error_text);
74 if ($object->getViewPolicy() != PhabricatorPolicies
::POLICY_PUBLIC
) {
75 $errors[] = $this->newInvalidError(
76 pht('For custom domains to work, the blog must have a view policy of '.
77 'public. This blog is currently set to "%s".',
78 $object->getViewPolicy()));
81 $domain = new PhutilURI($custom_domain);
82 $domain = $domain->getDomain();
83 $duplicate_blog = id(new PhameBlogQuery())
84 ->setViewer(PhabricatorUser
::getOmnipotentUser())
87 if ($duplicate_blog && $duplicate_blog->getID() != $object->getID()) {
88 $errors[] = $this->newInvalidError(
89 pht('Domain must be unique; another blog already has this domain.'));