diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1155,6 +1155,8 @@ 'HeraldNewObjectField' => 'applications/herald/field/HeraldNewObjectField.php', 'HeraldNotifyActionGroup' => 'applications/herald/action/HeraldNotifyActionGroup.php', 'HeraldObjectTranscript' => 'applications/herald/storage/transcript/HeraldObjectTranscript.php', + 'HeraldPhameBlogAdapter' => 'applications/phame/herald/HeraldPhameBlogAdapter.php', + 'HeraldPhamePostAdapter' => 'applications/phame/herald/HeraldPhamePostAdapter.php', 'HeraldPholioMockAdapter' => 'applications/pholio/herald/HeraldPholioMockAdapter.php', 'HeraldPonderQuestionAdapter' => 'applications/ponder/herald/HeraldPonderQuestionAdapter.php', 'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php', @@ -5213,6 +5215,8 @@ 'HeraldNewObjectField' => 'HeraldField', 'HeraldNotifyActionGroup' => 'HeraldActionGroup', 'HeraldObjectTranscript' => 'Phobject', + 'HeraldPhameBlogAdapter' => 'HeraldAdapter', + 'HeraldPhamePostAdapter' => 'HeraldAdapter', 'HeraldPholioMockAdapter' => 'HeraldAdapter', 'HeraldPonderQuestionAdapter' => 'HeraldAdapter', 'HeraldPreCommitAdapter' => 'HeraldAdapter', diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php --- a/src/applications/phame/editor/PhameBlogEditor.php +++ b/src/applications/phame/editor/PhameBlogEditor.php @@ -230,4 +230,18 @@ return false; } + protected function shouldApplyHeraldRules( + PhabricatorLiskDAO $object, + array $xactions) { + return true; + } + + protected function buildHeraldAdapter( + PhabricatorLiskDAO $object, + array $xactions) { + + return id(new HeraldPhameBlogAdapter()) + ->setBlog($object); + } + } diff --git a/src/applications/phame/editor/PhamePostEditor.php b/src/applications/phame/editor/PhamePostEditor.php --- a/src/applications/phame/editor/PhamePostEditor.php +++ b/src/applications/phame/editor/PhamePostEditor.php @@ -264,4 +264,18 @@ return false; } + protected function shouldApplyHeraldRules( + PhabricatorLiskDAO $object, + array $xactions) { + return true; + } + + protected function buildHeraldAdapter( + PhabricatorLiskDAO $object, + array $xactions) { + + return id(new HeraldPhamePostAdapter()) + ->setPost($object); + } + } diff --git a/src/applications/phame/herald/HeraldPhameBlogAdapter.php b/src/applications/phame/herald/HeraldPhameBlogAdapter.php new file mode 100644 --- /dev/null +++ b/src/applications/phame/herald/HeraldPhameBlogAdapter.php @@ -0,0 +1,62 @@ +<?php + +final class HeraldPhameBlogAdapter extends HeraldAdapter { + + private $blog; + + protected function newObject() { + return new PhameBlog(); + } + + public function getAdapterApplicationClass() { + return 'PhabricatorPhameApplication'; + } + + public function getAdapterContentDescription() { + return pht('React to Phame Blogs being created or updated.'); + } + + protected function initializeNewAdapter() { + $this->blog = $this->newObject(); + } + + public function supportsApplicationEmail() { + return true; + } + + public function getRepetitionOptions() { + return array( + HeraldRepetitionPolicyConfig::EVERY, + HeraldRepetitionPolicyConfig::FIRST, + ); + } + + public function supportsRuleType($rule_type) { + switch ($rule_type) { + case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: + case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: + return true; + case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: + default: + return false; + } + } + + public function setBlog(PhameBlog $blog) { + $this->blog = $blog; + return $this; + } + + public function getObject() { + return $this->blog; + } + + public function getAdapterContentName() { + return pht('Phame Blogs'); + } + + public function getHeraldName() { + return 'BLOG'.$this->getObject()->getID(); + } + +} diff --git a/src/applications/phame/herald/HeraldPhamePostAdapter.php b/src/applications/phame/herald/HeraldPhamePostAdapter.php new file mode 100644 --- /dev/null +++ b/src/applications/phame/herald/HeraldPhamePostAdapter.php @@ -0,0 +1,62 @@ +<?php + +final class HeraldPhamePostAdapter extends HeraldAdapter { + + private $post; + + protected function newObject() { + return new PhamePost(); + } + + public function getAdapterApplicationClass() { + return 'PhabricatorPhameApplication'; + } + + public function getAdapterContentDescription() { + return pht('React to Phame Posts being created or updated.'); + } + + protected function initializeNewAdapter() { + $this->post = $this->newObject(); + } + + public function supportsApplicationEmail() { + return true; + } + + public function getRepetitionOptions() { + return array( + HeraldRepetitionPolicyConfig::EVERY, + HeraldRepetitionPolicyConfig::FIRST, + ); + } + + public function supportsRuleType($rule_type) { + switch ($rule_type) { + case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: + case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: + return true; + case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: + default: + return false; + } + } + + public function setPost(PhamePost $post) { + $this->post = $post; + return $this; + } + + public function getObject() { + return $this->post; + } + + public function getAdapterContentName() { + return pht('Phame Posts'); + } + + public function getHeraldName() { + return 'POST'.$this->getObject()->getID(); + } + +}