Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/export/engine/PhabricatorSubscriptionsExportEngineExtension.php
12242 views
1
<?php
2
3
final class PhabricatorSubscriptionsExportEngineExtension
4
extends PhabricatorExportEngineExtension {
5
6
const EXTENSIONKEY = 'subscriptions';
7
8
public function supportsObject($object) {
9
return ($object instanceof PhabricatorSubscribableInterface);
10
}
11
12
public function newExportFields() {
13
return array(
14
id(new PhabricatorPHIDListExportField())
15
->setKey('subscriberPHIDs')
16
->setLabel(pht('Subscriber PHIDs')),
17
id(new PhabricatorStringListExportField())
18
->setKey('subscribers')
19
->setLabel(pht('Subscribers')),
20
);
21
}
22
23
public function newExportData(array $objects) {
24
$viewer = $this->getViewer();
25
26
$object_phids = mpull($objects, 'getPHID');
27
28
$projects_query = id(new PhabricatorEdgeQuery())
29
->withSourcePHIDs($object_phids)
30
->withEdgeTypes(
31
array(
32
PhabricatorObjectHasSubscriberEdgeType::EDGECONST,
33
));
34
$projects_query->execute();
35
36
$handles = $viewer->loadHandles($projects_query->getDestinationPHIDs());
37
38
$map = array();
39
foreach ($objects as $object) {
40
$object_phid = $object->getPHID();
41
42
$project_phids = $projects_query->getDestinationPHIDs(
43
array($object_phid),
44
array(PhabricatorObjectHasSubscriberEdgeType::EDGECONST));
45
46
$handle_list = $handles->newSublist($project_phids);
47
$handle_list = iterator_to_array($handle_list);
48
$handle_names = mpull($handle_list, 'getName');
49
$handle_names = array_values($handle_names);
50
51
$map[] = array(
52
'subscriberPHIDs' => $project_phids,
53
'subscribers' => $handle_names,
54
);
55
}
56
57
return $map;
58
}
59
60
}
61
62