2015-08-08 19:22:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class HeraldPonderQuestionAdapter extends HeraldAdapter {
|
|
|
|
|
|
|
|
private $question;
|
|
|
|
|
|
|
|
protected function newObject() {
|
|
|
|
return new PonderQuestion();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAdapterApplicationClass() {
|
|
|
|
return 'PhabricatorPonderApplication';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAdapterContentDescription() {
|
|
|
|
return pht('React to questions being created or updated.');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function initializeNewAdapter() {
|
|
|
|
$this->question = $this->newObject();
|
|
|
|
}
|
|
|
|
|
Make Herald test workflow modular and more clear
Summary:
Fixes T9719. Currently, the Herald "Test Console" has a big `instanceof` thing, so new adapters (like a Calendar adapter, or third-party adapters) aren't available automatically. Instead, do a standard modular thing: load the available adapters, ask which ones can test the object the user selected, then let the user pick which one they want to move forward with.
Additionally, it isn't very clear that you can't test "commit hook" rules because they rely on push state which we don't really have a good way to simulate. When the user picks a commit, we now show them the "Hook" events, but the options are disabled and explain why they can not be selected.
Test Plan:
- Ran test rules for revisions, commits, mocks, tasks, wiki documents, questions, and outbound mail.
- Plugged in a commit, got a more-helpful choice screen explaining why you do a test run of hook rules.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9719
Differential Revision: https://secure.phabricator.com/D16360
2016-08-01 22:29:46 +02:00
|
|
|
|
|
|
|
public function isTestAdapterForObject($object) {
|
|
|
|
return ($object instanceof PonderQuestion);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAdapterTestDescription() {
|
|
|
|
return pht(
|
|
|
|
'Test rules which run when a question is created or updated.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setObject($object) {
|
|
|
|
$this->question = $object;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-08-08 19:22:18 +02:00
|
|
|
public function supportsApplicationEmail() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 setQuestion(PonderQuestion $question) {
|
|
|
|
$this->question = $question;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getObject() {
|
|
|
|
return $this->question;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAdapterContentName() {
|
|
|
|
return pht('Ponder Questions');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeraldName() {
|
|
|
|
return 'Q'.$this->getObject()->getID();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|