Path: blob/master/src/applications/aphlict/query/AphlictDropdownDataQuery.php
12256 views
<?php12final class AphlictDropdownDataQuery extends Phobject {34private $viewer;5private $notificationData;6private $conpherenceData;78public function setViewer(PhabricatorUser $viewer) {9$this->viewer = $viewer;10return $this;11}1213public function getViewer() {14return $this->viewer;15}1617private function setNotificationData(array $data) {18$this->notificationData = $data;19return $this;20}2122public function getNotificationData() {23if ($this->notificationData === null) {24throw new Exception(pht('You must %s first!', 'execute()'));25}26return $this->notificationData;27}2829private function setConpherenceData(array $data) {30$this->conpherenceData = $data;31return $this;32}3334public function getConpherenceData() {35if ($this->conpherenceData === null) {36throw new Exception(pht('You must %s first!', 'execute()'));37}38return $this->conpherenceData;39}4041public function execute() {42$viewer = $this->getViewer();4344$conpherence_app = 'PhabricatorConpherenceApplication';45$is_c_installed = PhabricatorApplication::isClassInstalledForViewer(46$conpherence_app,47$viewer);48if ($is_c_installed) {49$raw_message_count_number = $viewer->getUnreadMessageCount();50$message_count_number = $this->formatNumber($raw_message_count_number);51} else {52$raw_message_count_number = null;53$message_count_number = null;54}555657$conpherence_data = array(58'isInstalled' => $is_c_installed,59'countType' => 'messages',60'count' => $message_count_number,61'rawCount' => $raw_message_count_number,62);63$this->setConpherenceData($conpherence_data);6465$notification_app = 'PhabricatorNotificationsApplication';66$is_n_installed = PhabricatorApplication::isClassInstalledForViewer(67$notification_app,68$viewer);69if ($is_n_installed) {70$raw_notification_count_number = $viewer->getUnreadNotificationCount();71$notification_count_number = $this->formatNumber(72$raw_notification_count_number);73} else {74$notification_count_number = null;75$raw_notification_count_number = null;76}7778$notification_data = array(79'isInstalled' => $is_n_installed,80'countType' => 'notifications',81'count' => $notification_count_number,82'rawCount' => $raw_notification_count_number,83);84$this->setNotificationData($notification_data);8586return array(87$notification_app => $this->getNotificationData(),88$conpherence_app => $this->getConpherenceData(),89);90}9192private function formatNumber($number) {93$formatted = $number;94if ($number > 999) {95$formatted = "\xE2\x88\x9E";96}97return $formatted;98}99100}101102103