@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at upstream/main 134 lines 3.1 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorPackagesQuery<PhabricatorPackagesPackage> 5 */ 6final class PhabricatorPackagesPackageQuery 7 extends PhabricatorPackagesQuery { 8 9 private $ids; 10 private $phids; 11 private $publisherPHIDs; 12 private $packageKeys; 13 private $fullKeys; 14 15 public function withIDs(array $ids) { 16 $this->ids = $ids; 17 return $this; 18 } 19 20 public function withPHIDs(array $phids) { 21 $this->phids = $phids; 22 return $this; 23 } 24 25 public function withPublisherPHIDs(array $phids) { 26 $this->publisherPHIDs = $phids; 27 return $this; 28 } 29 30 public function withPackageKeys(array $keys) { 31 $this->packageKeys = $keys; 32 return $this; 33 } 34 35 public function withFullKeys(array $keys) { 36 $this->fullKeys = $keys; 37 return $this; 38 } 39 40 public function withNameNgrams($ngrams) { 41 return $this->withNgramsConstraint( 42 new PhabricatorPackagesPackageNameNgrams(), 43 $ngrams); 44 } 45 46 public function newResultObject() { 47 return new PhabricatorPackagesPackage(); 48 } 49 50 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 51 $where = parent::buildWhereClauseParts($conn); 52 53 if ($this->ids !== null) { 54 $where[] = qsprintf( 55 $conn, 56 'p.id IN (%Ld)', 57 $this->ids); 58 } 59 60 if ($this->phids !== null) { 61 $where[] = qsprintf( 62 $conn, 63 'p.phid IN (%Ls)', 64 $this->phids); 65 } 66 67 if ($this->publisherPHIDs !== null) { 68 $where[] = qsprintf( 69 $conn, 70 'p.publisherPHID IN (%Ls)', 71 $this->publisherPHIDs); 72 } 73 74 if ($this->packageKeys !== null) { 75 $where[] = qsprintf( 76 $conn, 77 'p.packageKey IN (%Ls)', 78 $this->packageKeys); 79 } 80 81 if ($this->fullKeys !== null) { 82 $parts = $this->buildFullKeyClauseParts($conn, $this->fullKeys); 83 $where[] = qsprintf($conn, '%Q', $parts); 84 } 85 86 return $where; 87 } 88 89 protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { 90 $joins = parent::buildJoinClauseParts($conn); 91 92 $join_publisher = ($this->fullKeys !== null); 93 if ($join_publisher) { 94 $publisher_table = new PhabricatorPackagesPublisher(); 95 96 $joins[] = qsprintf( 97 $conn, 98 'JOIN %T u ON u.phid = p.publisherPHID', 99 $publisher_table->getTableName()); 100 } 101 102 return $joins; 103 } 104 105 protected function willFilterPage(array $packages) { 106 $publisher_phids = mpull($packages, 'getPublisherPHID'); 107 108 $publishers = id(new PhabricatorPackagesPublisherQuery()) 109 ->setViewer($this->getViewer()) 110 ->setParentQuery($this) 111 ->withPHIDs($publisher_phids) 112 ->execute(); 113 $publishers = mpull($publishers, null, 'getPHID'); 114 115 foreach ($packages as $key => $package) { 116 $publisher = idx($publishers, $package->getPublisherPHID()); 117 118 if (!$publisher) { 119 unset($packages[$key]); 120 $this->didRejectResult($package); 121 continue; 122 } 123 124 $package->attachPublisher($publisher); 125 } 126 127 return $packages; 128 } 129 130 protected function getPrimaryTableAlias() { 131 return 'p'; 132 } 133 134}