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 buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
48 $where = parent
::buildWhereClauseParts($conn);
50 if ($this->ids
!== null) {
57 if ($this->phids
!== null) {
64 if ($this->publisherPHIDs
!== null) {
67 'p.publisherPHID IN (%Ls)',
68 $this->publisherPHIDs
);
71 if ($this->packageKeys
!== null) {
74 'p.packageKey IN (%Ls)',
78 if ($this->fullKeys
!== null) {
79 $parts = $this->buildFullKeyClauseParts($conn, $this->fullKeys
);
80 $where[] = qsprintf($conn, '%Q', $parts);
86 protected function buildJoinClauseParts(AphrontDatabaseConnection
$conn) {
87 $joins = parent
::buildJoinClauseParts($conn);
89 $join_publisher = ($this->fullKeys
!== null);
90 if ($join_publisher) {
91 $publisher_table = new PhabricatorPackagesPublisher();
95 'JOIN %T u ON u.phid = p.publisherPHID',
96 $publisher_table->getTableName());
102 protected function willFilterPage(array $packages) {
103 $publisher_phids = mpull($packages, 'getPublisherPHID');
105 $publishers = id(new PhabricatorPackagesPublisherQuery())
106 ->setViewer($this->getViewer())
107 ->setParentQuery($this)
108 ->withPHIDs($publisher_phids)
110 $publishers = mpull($publishers, null, 'getPHID');
112 foreach ($packages as $key => $package) {
113 $publisher = idx($publishers, $package->getPublisherPHID());
116 unset($packages[$key]);
117 $this->didRejectResult($package);
121 $package->attachPublisher($publisher);
127 protected function getPrimaryTableAlias() {