mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 18:52:42 +01:00
7c2a7d0365
Summary: Modernize remaining edges to subclass `PhabricatorEdgeType`. Largely based on D11045. Test Plan: Browsed around and performed various actions include subscribing, unsubscribing and watching. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D11116
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorSubscribersQuery extends PhabricatorQuery {
|
|
|
|
private $objectPHIDs;
|
|
private $subscriberPHIDs;
|
|
|
|
public static function loadSubscribersForPHID($phid) {
|
|
if (!$phid) {
|
|
return array();
|
|
}
|
|
|
|
$subscribers = id(new PhabricatorSubscribersQuery())
|
|
->withObjectPHIDs(array($phid))
|
|
->execute();
|
|
return $subscribers[$phid];
|
|
}
|
|
|
|
public function withObjectPHIDs(array $object_phids) {
|
|
$this->objectPHIDs = $object_phids;
|
|
return $this;
|
|
}
|
|
|
|
public function withSubscriberPHIDs(array $subscriber_phids) {
|
|
$this->subscriberPHIDs = $subscriber_phids;
|
|
return $this;
|
|
}
|
|
|
|
public function execute() {
|
|
$query = new PhabricatorEdgeQuery();
|
|
|
|
$edge_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
|
|
|
|
$query->withSourcePHIDs($this->objectPHIDs);
|
|
$query->withEdgeTypes(array($edge_type));
|
|
|
|
if ($this->subscriberPHIDs) {
|
|
$query->withDestinationPHIDs($this->subscriberPHIDs);
|
|
}
|
|
|
|
$edges = $query->execute();
|
|
|
|
$results = array_fill_keys($this->objectPHIDs, array());
|
|
foreach ($edges as $src => $edge_types) {
|
|
foreach ($edge_types[$edge_type] as $dst => $data) {
|
|
$results[$src][] = $dst;
|
|
}
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
}
|