3 final class ReleephIntentFieldSpecification
4 extends ReleephFieldSpecification
{
6 public function getFieldKey() {
10 public function getName() {
14 public function getRequiredHandlePHIDsForPropertyView() {
15 $pull = $this->getReleephRequest();
16 $intents = $pull->getUserIntents();
17 return array_keys($intents);
20 public function renderPropertyViewValue(array $handles) {
21 $pull = $this->getReleephRequest();
23 $intents = $pull->getUserIntents();
24 $product = $this->getReleephProject();
33 foreach ($intents as $phid => $intent) {
34 if ($product->isAuthoritativePHID($phid)) {
35 $pushers[$phid] = $intent;
37 $others[$phid] = $intent;
41 $intents = $pushers +
$others;
43 $view = id(new PHUIStatusListView());
44 foreach ($intents as $phid => $intent) {
46 case ReleephRequest
::INTENT_WANT
:
47 $icon = PHUIStatusItemView
::ICON_ACCEPT
;
51 case ReleephRequest
::INTENT_PASS
:
52 $icon = PHUIStatusItemView
::ICON_REJECT
;
57 $icon = PHUIStatusItemView
::ICON_QUESTION
;
59 $label = pht('Unknown Intent (%s)', $intent);
63 $target = $handles[$phid]->renderLink();
64 if ($product->isAuthoritativePHID($phid)) {
65 $target = phutil_tag('strong', array(), $target);
69 id(new PHUIStatusItemView())
70 ->setIcon($icon, $color, $label)
71 ->setTarget($target));
77 public function shouldAppearOnCommitMessage() {
81 public function shouldAppearOnRevertMessage() {
85 public function renderLabelForCommitMessage() {
86 return pht('Approved By');
89 public function renderLabelForRevertMessage() {
90 return pht('Rejected By');
93 public function renderValueForCommitMessage() {
94 return $this->renderIntentsForCommitMessage(ReleephRequest
::INTENT_WANT
);
97 public function renderValueForRevertMessage() {
98 return $this->renderIntentsForCommitMessage(ReleephRequest
::INTENT_PASS
);
101 private function renderIntentsForCommitMessage($print_intent) {
102 $intents = $this->getReleephRequest()->getUserIntents();
104 $requestor = $this->getReleephRequest()->getRequestUserPHID();
105 $pusher_phids = $this->getReleephProject()->getPushers();
107 $phids = array_unique($pusher_phids +
array_keys($intents));
108 $handles = id(new PhabricatorHandleQuery())
109 ->setViewer($this->getUser())
114 foreach ($phids as $phid) {
115 $intent = idx($intents, $phid);
116 if ($intent == $print_intent) {
117 $name = $handles[$phid]->getName();
118 $is_pusher = in_array($phid, $pusher_phids);
119 $is_requestor = $phid == $requestor;
123 $token = pht('%s (pusher and requestor)', $name);
125 $token = "{$name} (pusher)";
129 $token = pht('%s (requestor)', $name);
139 return implode(', ', $tokens);