Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / herald / HeraldPreCommitAdapter.php
blobf63f647da6c5fe6630974c91e2a1a0b2713ac185
1 <?php
3 abstract class HeraldPreCommitAdapter extends HeraldAdapter {
5 private $log;
6 private $hookEngine;
8 abstract public function isPreCommitRefAdapter();
10 public function setPushLog(PhabricatorRepositoryPushLog $log) {
11 $this->log = $log;
12 return $this;
15 public function setHookEngine(DiffusionCommitHookEngine $engine) {
16 $this->hookEngine = $engine;
17 return $this;
20 public function getHookEngine() {
21 return $this->hookEngine;
24 public function getAdapterApplicationClass() {
25 return 'PhabricatorDiffusionApplication';
28 public function isTestAdapterForObject($object) {
29 return ($object instanceof PhabricatorRepositoryCommit);
32 public function canCreateTestAdapterForObject($object) {
33 return false;
36 public function getAdapterTestDescription() {
37 return pht(
38 'Commit hook events depend on repository state which is only available '.
39 'at push time, and can not be run in test mode.');
42 protected function initializeNewAdapter() {
43 $this->log = new PhabricatorRepositoryPushLog();
46 public function isSingleEventAdapter() {
47 return true;
50 public function getObject() {
51 return $this->log;
54 public function supportsRuleType($rule_type) {
55 switch ($rule_type) {
56 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
57 case HeraldRuleTypeConfig::RULE_TYPE_OBJECT:
58 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
59 return true;
60 default:
61 return false;
65 public function canTriggerOnObject($object) {
66 if ($object instanceof PhabricatorRepository) {
67 return true;
70 if ($object instanceof PhabricatorProject) {
71 return true;
74 return false;
77 public function explainValidTriggerObjects() {
78 return pht('This rule can trigger for **repositories** or **projects**.');
81 public function getTriggerObjectPHIDs() {
82 return array_merge(
83 array(
84 $this->hookEngine->getRepository()->getPHID(),
85 $this->getPHID(),
87 $this->hookEngine->getRepository()->getProjectPHIDs());
90 public function supportsWebhooks() {
91 return false;