Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/doorkeeper/engine/DoorkeeperFeedStoryPublisher.php
12256 views
1
<?php
2
3
/**
4
* @task config Configuration
5
*/
6
abstract class DoorkeeperFeedStoryPublisher extends Phobject {
7
8
private $feedStory;
9
private $viewer;
10
private $renderWithImpliedContext;
11
12
13
/* -( Configuration )------------------------------------------------------ */
14
15
16
/**
17
* Render story text using contextual language to identify the object the
18
* story is about, instead of the full object name. For example, without
19
* contextual language a story might render like this:
20
*
21
* alincoln created D123: Chop Wood for Log Cabin v2.0
22
*
23
* With contextual language, it will render like this instead:
24
*
25
* alincoln created this revision.
26
*
27
* If the interface where the text will be displayed is specific to an
28
* individual object (like Asana tasks that represent one review or commit
29
* are), it's generally more natural to use language that assumes context.
30
* If the target context may show information about several objects (like
31
* JIRA issues which can have several linked revisions), it's generally
32
* more useful not to assume context.
33
*
34
* @param bool True to assume object context when rendering.
35
* @return this
36
* @task config
37
*/
38
public function setRenderWithImpliedContext($render_with_implied_context) {
39
$this->renderWithImpliedContext = $render_with_implied_context;
40
return $this;
41
}
42
43
/**
44
* Determine if rendering should assume object context. For discussion, see
45
* @{method:setRenderWithImpliedContext}.
46
*
47
* @return bool True if rendering should assume object context is implied.
48
* @task config
49
*/
50
public function getRenderWithImpliedContext() {
51
return $this->renderWithImpliedContext;
52
}
53
54
public function setFeedStory(PhabricatorFeedStory $feed_story) {
55
$this->feedStory = $feed_story;
56
return $this;
57
}
58
59
public function getFeedStory() {
60
return $this->feedStory;
61
}
62
63
public function setViewer(PhabricatorUser $viewer) {
64
$this->viewer = $viewer;
65
return $this;
66
}
67
68
public function getViewer() {
69
return $this->viewer;
70
}
71
72
abstract public function canPublishStory(
73
PhabricatorFeedStory $story,
74
$object);
75
76
/**
77
* Hook for publishers to mutate the story object, particularly by loading
78
* and attaching additional data.
79
*/
80
public function willPublishStory($object) {
81
return $object;
82
}
83
84
85
public function getStoryText($object) {
86
return $this->getFeedStory()->renderAsTextForDoorkeeper($this);
87
}
88
89
abstract public function isStoryAboutObjectCreation($object);
90
abstract public function isStoryAboutObjectClosure($object);
91
abstract public function getOwnerPHID($object);
92
abstract public function getActiveUserPHIDs($object);
93
abstract public function getPassiveUserPHIDs($object);
94
abstract public function getCCUserPHIDs($object);
95
abstract public function getObjectTitle($object);
96
abstract public function getObjectURI($object);
97
abstract public function getObjectDescription($object);
98
abstract public function isObjectClosed($object);
99
abstract public function getResponsibilityTitle($object);
100
101
}
102
103