Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / differential / query / DifferentialRevisionResultBucket.php
blobc5cc5c0e6ca302ec3eda425f5134b40ec9a71c75
1 <?php
3 abstract class DifferentialRevisionResultBucket
4 extends PhabricatorSearchResultBucket {
6 public static function getAllResultBuckets() {
7 return id(new PhutilClassMapQuery())
8 ->setAncestorClass(__CLASS__)
9 ->setUniqueMethod('getResultBucketKey')
10 ->execute();
13 protected function getRevisionsUnderReview(array $objects, array $phids) {
14 $results = array();
16 $objects = $this->getRevisionsNotAuthored($objects, $phids);
18 foreach ($objects as $key => $object) {
19 if (!$object->isNeedsReview()) {
20 continue;
23 $results[$key] = $object;
26 return $results;
29 protected function getRevisionsAuthored(array $objects, array $phids) {
30 $results = array();
32 foreach ($objects as $key => $object) {
33 if (isset($phids[$object->getAuthorPHID()])) {
34 $results[$key] = $object;
38 return $results;
41 protected function getRevisionsNotAuthored(array $objects, array $phids) {
42 $results = array();
44 foreach ($objects as $key => $object) {
45 if (empty($phids[$object->getAuthorPHID()])) {
46 $results[$key] = $object;
50 return $results;
53 protected function hasReviewersWithStatus(
54 DifferentialRevision $revision,
55 array $phids,
56 array $statuses,
57 $include_voided = null) {
59 foreach ($revision->getReviewers() as $reviewer) {
60 $reviewer_phid = $reviewer->getReviewerPHID();
61 if (empty($phids[$reviewer_phid])) {
62 continue;
65 $status = $reviewer->getReviewerStatus();
66 if (empty($statuses[$status])) {
67 continue;
70 if ($include_voided !== null) {
71 if ($status == DifferentialReviewerStatus::STATUS_ACCEPTED) {
72 $is_voided = (bool)$reviewer->getVoidedPHID();
73 if ($is_voided !== $include_voided) {
74 continue;
79 return true;
82 return false;