Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
1.7 kB · 63 lines
PHP
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364<?php
final class PhabricatorSubscriptionsExportEngineExtension extends PhabricatorExportEngineExtension {
const EXTENSIONKEY = 'subscriptions';
public function supportsObject($object) { return ($object instanceof PhabricatorSubscribableInterface); }
public function newExportFields() { return array( id(new PhabricatorPHIDListExportField()) ->setKey('subscriberPHIDs') ->setLabel(pht('Subscriber PHIDs')), id(new PhabricatorStringListExportField()) ->setKey('subscribers') ->setLabel(pht('Subscribers')), ); }
public function newExportData(array $objects) { $viewer = $this->getViewer();
$object_phids = mpull($objects, 'getPHID'); if (!$object_phids) { return array(); }
$projects_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($object_phids) ->withEdgeTypes( array( PhabricatorObjectHasSubscriberEdgeType::EDGECONST, )); $projects_query->execute();
$handles = $viewer->loadHandles($projects_query->getDestinationPHIDs());
$map = array(); foreach ($objects as $object) { $object_phid = $object->getPHID();
$project_phids = $projects_query->getDestinationPHIDs( array($object_phid), array(PhabricatorObjectHasSubscriberEdgeType::EDGECONST));
$handle_list = $handles->newSublist($project_phids); $handle_list = iterator_to_array($handle_list); $handle_names = mpull($handle_list, 'getName'); $handle_names = array_values($handle_names);
$map[] = array( 'subscriberPHIDs' => $project_phids, 'subscribers' => $handle_names, ); }
return $map; }
}