mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Add Herald Adapters to Phame
Summary: Adds a basic HeraldAdapter to Phame Blogs and Posts. Test Plan: Make a Herald rule to CC me on new posts or blogs automatically. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14897
This commit is contained in:
parent
b471ebe987
commit
744215d5ff
5 changed files with 156 additions and 0 deletions
|
@ -1155,6 +1155,8 @@ phutil_register_library_map(array(
|
|||
'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 @@ phutil_register_library_map(array(
|
|||
'HeraldNewObjectField' => 'HeraldField',
|
||||
'HeraldNotifyActionGroup' => 'HeraldActionGroup',
|
||||
'HeraldObjectTranscript' => 'Phobject',
|
||||
'HeraldPhameBlogAdapter' => 'HeraldAdapter',
|
||||
'HeraldPhamePostAdapter' => 'HeraldAdapter',
|
||||
'HeraldPholioMockAdapter' => 'HeraldAdapter',
|
||||
'HeraldPonderQuestionAdapter' => 'HeraldAdapter',
|
||||
'HeraldPreCommitAdapter' => 'HeraldAdapter',
|
||||
|
|
|
@ -230,4 +230,18 @@ final class PhameBlogEditor
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function shouldApplyHeraldRules(
|
||||
PhabricatorLiskDAO $object,
|
||||
array $xactions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function buildHeraldAdapter(
|
||||
PhabricatorLiskDAO $object,
|
||||
array $xactions) {
|
||||
|
||||
return id(new HeraldPhameBlogAdapter())
|
||||
->setBlog($object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -264,4 +264,18 @@ final class PhamePostEditor
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function shouldApplyHeraldRules(
|
||||
PhabricatorLiskDAO $object,
|
||||
array $xactions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function buildHeraldAdapter(
|
||||
PhabricatorLiskDAO $object,
|
||||
array $xactions) {
|
||||
|
||||
return id(new HeraldPhamePostAdapter())
|
||||
->setPost($object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
62
src/applications/phame/herald/HeraldPhameBlogAdapter.php
Normal file
62
src/applications/phame/herald/HeraldPhameBlogAdapter.php
Normal file
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
62
src/applications/phame/herald/HeraldPhamePostAdapter.php
Normal file
62
src/applications/phame/herald/HeraldPhamePostAdapter.php
Normal file
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue