Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/query/PhabricatorOwnersPackageQuery.php
<?php | <?php | ||||
final class PhabricatorOwnersPackageQuery | final class PhabricatorOwnersPackageQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $ownerPHIDs; | private $ownerPHIDs; | ||||
private $authorityPHIDs; | private $authorityPHIDs; | ||||
private $repositoryPHIDs; | private $repositoryPHIDs; | ||||
private $paths; | private $paths; | ||||
private $namePrefix; | |||||
private $statuses; | private $statuses; | ||||
private $controlMap = array(); | private $controlMap = array(); | ||||
private $controlResults; | private $controlResults; | ||||
private $needPaths; | private $needPaths; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | public function withControl($repository_phid, array $paths) { | ||||
} | } | ||||
// We need to load paths to execute control queries. | // We need to load paths to execute control queries. | ||||
$this->needPaths = true; | $this->needPaths = true; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withNamePrefix($prefix) { | public function withNameNgrams($ngrams) { | ||||
$this->namePrefix = $prefix; | return $this->withNgramsConstraint( | ||||
return $this; | new PhabricatorOwnersPackageNameNgrams(), | ||||
$ngrams); | |||||
} | } | ||||
public function needPaths($need_paths) { | public function needPaths($need_paths) { | ||||
$this->needPaths = $need_paths; | $this->needPaths = $need_paths; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function newResultObject() { | public function newResultObject() { | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->statuses !== null) { | if ($this->statuses !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'p.status IN (%Ls)', | 'p.status IN (%Ls)', | ||||
$this->statuses); | $this->statuses); | ||||
} | } | ||||
if (strlen($this->namePrefix)) { | |||||
// NOTE: This is a hacky mess, but this column is currently case | |||||
// sensitive and unique. | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'LOWER(p.name) LIKE %>', | |||||
phutil_utf8_strtolower($this->namePrefix)); | |||||
} | |||||
if ($this->controlMap) { | if ($this->controlMap) { | ||||
$clauses = array(); | $clauses = array(); | ||||
foreach ($this->controlMap as $repository_phid => $paths) { | foreach ($this->controlMap as $repository_phid => $paths) { | ||||
$fragments = $this->getFragmentsForPaths($paths); | $fragments = $this->getFragmentsForPaths($paths); | ||||
$clauses[] = qsprintf( | $clauses[] = qsprintf( | ||||
$conn, | $conn, | ||||
'(rpath.repositoryPHID = %s AND rpath.path IN (%Ls))', | '(rpath.repositoryPHID = %s AND rpath.path IN (%Ls))', | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |