@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
at recaptime-dev/main 111 lines 2.3 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorPhurlURL> 5 */ 6final class PhabricatorPhurlURLQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $names; 12 private $longURLs; 13 private $aliases; 14 private $authorPHIDs; 15 16 public function newResultObject() { 17 return new PhabricatorPhurlURL(); 18 } 19 20 public function withIDs(array $ids) { 21 $this->ids = $ids; 22 return $this; 23 } 24 25 public function withPHIDs(array $phids) { 26 $this->phids = $phids; 27 return $this; 28 } 29 30 public function withNames(array $names) { 31 $this->names = $names; 32 return $this; 33 } 34 35 public function withNameNgrams($ngrams) { 36 return $this->withNgramsConstraint( 37 id(new PhabricatorPhurlURLNameNgrams()), 38 $ngrams); 39 } 40 41 public function withLongURLs(array $long_urls) { 42 $this->longURLs = $long_urls; 43 return $this; 44 } 45 46 public function withAliases(array $aliases) { 47 $this->aliases = $aliases; 48 return $this; 49 } 50 51 public function withAuthorPHIDs(array $author_phids) { 52 $this->authorPHIDs = $author_phids; 53 return $this; 54 } 55 56 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 57 $where = parent::buildWhereClauseParts($conn); 58 59 if ($this->ids !== null) { 60 $where[] = qsprintf( 61 $conn, 62 'url.id IN (%Ld)', 63 $this->ids); 64 } 65 66 if ($this->phids !== null) { 67 $where[] = qsprintf( 68 $conn, 69 'url.phid IN (%Ls)', 70 $this->phids); 71 } 72 73 if ($this->authorPHIDs !== null) { 74 $where[] = qsprintf( 75 $conn, 76 'url.authorPHID IN (%Ls)', 77 $this->authorPHIDs); 78 } 79 80 if ($this->names !== null) { 81 $where[] = qsprintf( 82 $conn, 83 'url.name IN (%Ls)', 84 $this->names); 85 } 86 87 if ($this->longURLs !== null) { 88 $where[] = qsprintf( 89 $conn, 90 'url.longURL IN (%Ls)', 91 $this->longURLs); 92 } 93 94 if ($this->aliases !== null) { 95 $where[] = qsprintf( 96 $conn, 97 'url.alias IN (%Ls)', 98 $this->aliases); 99 } 100 101 return $where; 102 } 103 104 protected function getPrimaryTableAlias() { 105 return 'url'; 106 } 107 108 public function getQueryApplicationClass() { 109 return PhabricatorPhurlApplication::class; 110 } 111}