true, self::CONFIG_SERIALIZATION => array( 'configData' => self::SERIALIZATION_JSON, ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhabricatorPHIDConstants::PHID_TYPE_BLOG); } /** * Makes sure a given custom blog uri is properly configured in DNS * to point at this Phabricator instance. If there is an error in * the configuration, return a string describing the error and how * to fix it. If there is no error, return an empty string. * * @return string */ public function validateCustomDomain($custom_domain) { $example_domain = '(e.g. blog.example.com)'; $valid = ''; // note this "uri" should be pretty busted given the desired input // so just use it to test if there's a protocol specified $uri = new PhutilURI($custom_domain); if ($uri->getProtocol()) { return 'Do not specify a protocol, just the domain. '.$example_domain; } if (strpos($custom_domain, '/') !== false) { return 'Do not specify a path, just the domain. '.$example_domain; } if (strpos($custom_domain, '.') === false) { return 'Custom domain must contain at least one dot (.) because '. 'some browsers fail to set cookies on domains such as '. 'http://example. '.$example_domain; } return $valid; } public function loadBloggerPHIDs() { if (!$this->getPHID()) { return $this; } if ($this->bloggerPHIDs) { return $this; } $this->bloggerPHIDs = PhabricatorEdgeQuery::loadDestinationPHIDs( $this->getPHID(), PhabricatorEdgeConfig::TYPE_BLOG_HAS_BLOGGER ); return $this; } public function getBloggerPHIDs() { if ($this->bloggerPHIDs === null) { throw new Exception( 'You must loadBloggerPHIDs before you can getBloggerPHIDs!' ); } return $this->bloggerPHIDs; } public function loadBloggers() { if ($this->bloggers) { return $this->bloggers; } $blogger_phids = $this->loadBloggerPHIDs()->getBloggerPHIDs(); if (empty($blogger_phids)) { return array(); } $bloggers = id(new PhabricatorObjectHandleData($blogger_phids)) ->loadHandles(); $this->attachBloggers($bloggers); return $this; } public function attachBloggers(array $bloggers) { assert_instances_of($bloggers, 'PhabricatorObjectHandle'); $this->bloggers = $bloggers; return $this; } public function getBloggers() { if ($this->bloggers === null) { throw new Exception( 'You must loadBloggers or attachBloggers before you can getBloggers!' ); } return $this->bloggers; } public function getPostListURI() { return $this->getActionURI('posts'); } public function getViewURI() { return $this->getActionURI('view'); } public function getEditURI() { return $this->getActionURI('edit'); } public function getEditFilter() { return 'blog/edit/'.$this->getPHID(); } public function getDeleteURI() { return $this->getActionURI('delete'); } private function getActionURI($action) { return '/phame/blog/'.$action.'/'.$this->getPHID().'/'; } }