3 final class PhabricatorPackagesPackageQuery
4 extends PhabricatorPackagesQuery
{
8 private $publisherPHIDs;
12 public function withIDs(array $ids) {
17 public function withPHIDs(array $phids) {
18 $this->phids
= $phids;
22 public function withPublisherPHIDs(array $phids) {
23 $this->publisherPHIDs
= $phids;
27 public function withPackageKeys(array $keys) {
28 $this->packageKeys
= $keys;
32 public function withFullKeys(array $keys) {
33 $this->fullKeys
= $keys;
37 public function withNameNgrams($ngrams) {
38 return $this->withNgramsConstraint(
39 new PhabricatorPackagesPackageNameNgrams(),
43 public function newResultObject() {
44 return new PhabricatorPackagesPackage();
47 protected function loadPage() {
48 return $this->loadStandardPage($this->newResultObject());
51 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
52 $where = parent
::buildWhereClauseParts($conn);
54 if ($this->ids
!== null) {
61 if ($this->phids
!== null) {
68 if ($this->publisherPHIDs
!== null) {
71 'p.publisherPHID IN (%Ls)',
72 $this->publisherPHIDs
);
75 if ($this->packageKeys
!== null) {
78 'p.packageKey IN (%Ls)',
82 if ($this->fullKeys
!== null) {
83 $parts = $this->buildFullKeyClauseParts($conn, $this->fullKeys
);
84 $where[] = qsprintf($conn, '%Q', $parts);
90 protected function buildJoinClauseParts(AphrontDatabaseConnection
$conn) {
91 $joins = parent
::buildJoinClauseParts($conn);
93 $join_publisher = ($this->fullKeys
!== null);
94 if ($join_publisher) {
95 $publisher_table = new PhabricatorPackagesPublisher();
99 'JOIN %T u ON u.phid = p.publisherPHID',
100 $publisher_table->getTableName());
106 protected function willFilterPage(array $packages) {
107 $publisher_phids = mpull($packages, 'getPublisherPHID');
109 $publishers = id(new PhabricatorPackagesPublisherQuery())
110 ->setViewer($this->getViewer())
111 ->setParentQuery($this)
112 ->withPHIDs($publisher_phids)
114 $publishers = mpull($publishers, null, 'getPHID');
116 foreach ($packages as $key => $package) {
117 $publisher = idx($publishers, $package->getPublisherPHID());
120 unset($packages[$key]);
121 $this->didRejectResult($package);
125 $package->attachPublisher($publisher);
131 protected function getPrimaryTableAlias() {