Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / aphlict / query / AphlictDropdownDataQuery.php
blob7a15ec7f648087ed3ebeb76de461eab8bc9cfa91
1 <?php
3 final class AphlictDropdownDataQuery extends Phobject {
5 private $viewer;
6 private $notificationData;
7 private $conpherenceData;
9 public function setViewer(PhabricatorUser $viewer) {
10 $this->viewer = $viewer;
11 return $this;
14 public function getViewer() {
15 return $this->viewer;
18 private function setNotificationData(array $data) {
19 $this->notificationData = $data;
20 return $this;
23 public function getNotificationData() {
24 if ($this->notificationData === null) {
25 throw new Exception(pht('You must %s first!', 'execute()'));
27 return $this->notificationData;
30 private function setConpherenceData(array $data) {
31 $this->conpherenceData = $data;
32 return $this;
35 public function getConpherenceData() {
36 if ($this->conpherenceData === null) {
37 throw new Exception(pht('You must %s first!', 'execute()'));
39 return $this->conpherenceData;
42 public function execute() {
43 $viewer = $this->getViewer();
45 $conpherence_app = 'PhabricatorConpherenceApplication';
46 $is_c_installed = PhabricatorApplication::isClassInstalledForViewer(
47 $conpherence_app,
48 $viewer);
49 if ($is_c_installed) {
50 $raw_message_count_number = $viewer->getUnreadMessageCount();
51 $message_count_number = $this->formatNumber($raw_message_count_number);
52 } else {
53 $raw_message_count_number = null;
54 $message_count_number = null;
58 $conpherence_data = array(
59 'isInstalled' => $is_c_installed,
60 'countType' => 'messages',
61 'count' => $message_count_number,
62 'rawCount' => $raw_message_count_number,
64 $this->setConpherenceData($conpherence_data);
66 $notification_app = 'PhabricatorNotificationsApplication';
67 $is_n_installed = PhabricatorApplication::isClassInstalledForViewer(
68 $notification_app,
69 $viewer);
70 if ($is_n_installed) {
71 $raw_notification_count_number = $viewer->getUnreadNotificationCount();
72 $notification_count_number = $this->formatNumber(
73 $raw_notification_count_number);
74 } else {
75 $notification_count_number = null;
76 $raw_notification_count_number = null;
79 $notification_data = array(
80 'isInstalled' => $is_n_installed,
81 'countType' => 'notifications',
82 'count' => $notification_count_number,
83 'rawCount' => $raw_notification_count_number,
85 $this->setNotificationData($notification_data);
87 return array(
88 $notification_app => $this->getNotificationData(),
89 $conpherence_app => $this->getConpherenceData(),
93 private function formatNumber($number) {
94 $formatted = $number;
95 if ($number > 999) {
96 $formatted = "\xE2\x88\x9E";
98 return $formatted;