@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class HeraldPonderQuestionAdapter extends HeraldAdapter {
4
5 private $question;
6
7 protected function newObject() {
8 return new PonderQuestion();
9 }
10
11 public function getAdapterApplicationClass() {
12 return PhabricatorPonderApplication::class;
13 }
14
15 public function getAdapterContentDescription() {
16 return pht('React to questions being created or updated.');
17 }
18
19 protected function initializeNewAdapter() {
20 $this->question = $this->newObject();
21 }
22
23
24 public function isTestAdapterForObject($object) {
25 return ($object instanceof PonderQuestion);
26 }
27
28 public function getAdapterTestDescription() {
29 return pht(
30 'Test rules which run when a question is created or updated.');
31 }
32
33 public function setObject($object) {
34 $this->question = $object;
35 return $this;
36 }
37
38 public function supportsApplicationEmail() {
39 return true;
40 }
41
42 public function supportsRuleType($rule_type) {
43 switch ($rule_type) {
44 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
45 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
46 return true;
47 case HeraldRuleTypeConfig::RULE_TYPE_OBJECT:
48 default:
49 return false;
50 }
51 }
52
53 public function setQuestion(PonderQuestion $question) {
54 $this->question = $question;
55 return $this;
56 }
57
58 public function getObject() {
59 return $this->question;
60 }
61
62 public function getAdapterContentName() {
63 return pht('Ponder Questions');
64 }
65
66 public function getHeraldName() {
67 return 'Q'.$this->getObject()->getID();
68 }
69
70}