Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / phurl / query / PhabricatorPhurlURLQuery.php
blob6efbbd5b4c3fae3d70b66e488f8c35643ac9fd68
1 <?php
3 final class PhabricatorPhurlURLQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $phids;
8 private $names;
9 private $longURLs;
10 private $aliases;
11 private $authorPHIDs;
13 public function newResultObject() {
14 return new PhabricatorPhurlURL();
17 public function withIDs(array $ids) {
18 $this->ids = $ids;
19 return $this;
22 public function withPHIDs(array $phids) {
23 $this->phids = $phids;
24 return $this;
27 public function withNames(array $names) {
28 $this->names = $names;
29 return $this;
32 public function withNameNgrams($ngrams) {
33 return $this->withNgramsConstraint(
34 id(new PhabricatorPhurlURLNameNgrams()),
35 $ngrams);
38 public function withLongURLs(array $long_urls) {
39 $this->longURLs = $long_urls;
40 return $this;
43 public function withAliases(array $aliases) {
44 $this->aliases = $aliases;
45 return $this;
48 public function withAuthorPHIDs(array $author_phids) {
49 $this->authorPHIDs = $author_phids;
50 return $this;
53 protected function loadPage() {
54 return $this->loadStandardPage($this->newResultObject());
57 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
58 $where = parent::buildWhereClauseParts($conn);
60 if ($this->ids !== null) {
61 $where[] = qsprintf(
62 $conn,
63 'url.id IN (%Ld)',
64 $this->ids);
67 if ($this->phids !== null) {
68 $where[] = qsprintf(
69 $conn,
70 'url.phid IN (%Ls)',
71 $this->phids);
74 if ($this->authorPHIDs !== null) {
75 $where[] = qsprintf(
76 $conn,
77 'url.authorPHID IN (%Ls)',
78 $this->authorPHIDs);
81 if ($this->names !== null) {
82 $where[] = qsprintf(
83 $conn,
84 'url.name IN (%Ls)',
85 $this->names);
88 if ($this->longURLs !== null) {
89 $where[] = qsprintf(
90 $conn,
91 'url.longURL IN (%Ls)',
92 $this->longURLs);
95 if ($this->aliases !== null) {
96 $where[] = qsprintf(
97 $conn,
98 'url.alias IN (%Ls)',
99 $this->aliases);
102 return $where;
105 protected function getPrimaryTableAlias() {
106 return 'url';
109 public function getQueryApplicationClass() {
110 return 'PhabricatorPhurlApplication';