Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php
12256 views
1
<?php
2
3
final class DifferentialDoorkeeperRevisionFeedStoryPublisher
4
extends DoorkeeperFeedStoryPublisher {
5
6
public function canPublishStory(PhabricatorFeedStory $story, $object) {
7
return ($object instanceof DifferentialRevision);
8
}
9
10
public function isStoryAboutObjectCreation($object) {
11
$story = $this->getFeedStory();
12
$action = $story->getStoryData()->getValue('action');
13
14
return ($action == DifferentialAction::ACTION_CREATE);
15
}
16
17
public function isStoryAboutObjectClosure($object) {
18
$story = $this->getFeedStory();
19
$action = $story->getStoryData()->getValue('action');
20
21
return ($action == DifferentialAction::ACTION_CLOSE) ||
22
($action == DifferentialAction::ACTION_ABANDON);
23
}
24
25
public function willPublishStory($object) {
26
return id(new DifferentialRevisionQuery())
27
->setViewer($this->getViewer())
28
->withIDs(array($object->getID()))
29
->needReviewers(true)
30
->executeOne();
31
}
32
33
public function getOwnerPHID($object) {
34
return $object->getAuthorPHID();
35
}
36
37
public function getActiveUserPHIDs($object) {
38
if ($object->isNeedsReview()) {
39
return $object->getReviewerPHIDs();
40
} else {
41
return array();
42
}
43
}
44
45
public function getPassiveUserPHIDs($object) {
46
if ($object->isNeedsReview()) {
47
return array();
48
} else {
49
return $object->getReviewerPHIDs();
50
}
51
}
52
53
public function getCCUserPHIDs($object) {
54
return PhabricatorSubscribersQuery::loadSubscribersForPHID(
55
$object->getPHID());
56
}
57
58
public function getObjectTitle($object) {
59
$id = $object->getID();
60
61
$title = $object->getTitle();
62
63
return "D{$id}: {$title}";
64
}
65
66
public function getObjectURI($object) {
67
return PhabricatorEnv::getProductionURI('/D'.$object->getID());
68
}
69
70
public function getObjectDescription($object) {
71
return $object->getSummary();
72
}
73
74
public function isObjectClosed($object) {
75
return $object->isClosed();
76
}
77
78
public function getResponsibilityTitle($object) {
79
$prefix = $this->getTitlePrefix($object);
80
return pht('%s Review Request', $prefix);
81
}
82
83
private function getTitlePrefix(DifferentialRevision $revision) {
84
return pht('[Differential]');
85
}
86
87
}
88
89