Differential D20911 Diff 49833 src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php
<?php | <?php | ||||
final class PhabricatorRepositoryIdentityQuery | final class PhabricatorRepositoryIdentityQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $identityNames; | private $identityNames; | ||||
private $emailAddresses; | private $emailAddresses; | ||||
private $assignedPHIDs; | private $assignedPHIDs; | ||||
private $effectivePHIDs; | private $effectivePHIDs; | ||||
private $identityNameLike; | private $identityNameLike; | ||||
private $hasEffectivePHID; | private $hasEffectivePHID; | ||||
private $relatedPHIDs; | |||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
$this->ids = $ids; | $this->ids = $ids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPHIDs(array $phids) { | public function withPHIDs(array $phids) { | ||||
$this->phids = $phids; | $this->phids = $phids; | ||||
Show All 20 Lines | public function withAssignedPHIDs(array $assigned) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withEffectivePHIDs(array $effective) { | public function withEffectivePHIDs(array $effective) { | ||||
$this->effectivePHIDs = $effective; | $this->effectivePHIDs = $effective; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withRelatedPHIDs(array $related) { | |||||
$this->relatedPHIDs = $related; | |||||
return $this; | |||||
} | |||||
public function withHasEffectivePHID($has_effective_phid) { | public function withHasEffectivePHID($has_effective_phid) { | ||||
$this->hasEffectivePHID = $has_effective_phid; | $this->hasEffectivePHID = $has_effective_phid; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function newResultObject() { | public function newResultObject() { | ||||
return new PhabricatorRepositoryIdentity(); | return new PhabricatorRepositoryIdentity(); | ||||
} | } | ||||
protected function getPrimaryTableAlias() { | protected function getPrimaryTableAlias() { | ||||
return 'repository_identity'; | return 'identity'; | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | return $this->loadStandardPage($this->newResultObject()); | ||||
} | } | ||||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = parent::buildWhereClauseParts($conn); | $where = parent::buildWhereClauseParts($conn); | ||||
if ($this->ids !== null) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.id IN (%Ld)', | 'identity.id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids !== null) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.phid IN (%Ls)', | 'identity.phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->assignedPHIDs !== null) { | if ($this->assignedPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.manuallySetUserPHID IN (%Ls)', | 'identity.manuallySetUserPHID IN (%Ls)', | ||||
$this->assignedPHIDs); | $this->assignedPHIDs); | ||||
} | } | ||||
if ($this->effectivePHIDs !== null) { | if ($this->effectivePHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.currentEffectiveUserPHID IN (%Ls)', | 'identity.currentEffectiveUserPHID IN (%Ls)', | ||||
$this->effectivePHIDs); | $this->effectivePHIDs); | ||||
} | } | ||||
if ($this->hasEffectivePHID !== null) { | if ($this->hasEffectivePHID !== null) { | ||||
if ($this->hasEffectivePHID) { | if ($this->hasEffectivePHID) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.currentEffectiveUserPHID IS NOT NULL'); | 'identity.currentEffectiveUserPHID IS NOT NULL'); | ||||
} else { | } else { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.currentEffectiveUserPHID IS NULL'); | 'identity.currentEffectiveUserPHID IS NULL'); | ||||
} | } | ||||
} | } | ||||
if ($this->identityNames !== null) { | if ($this->identityNames !== null) { | ||||
$name_hashes = array(); | $name_hashes = array(); | ||||
foreach ($this->identityNames as $name) { | foreach ($this->identityNames as $name) { | ||||
$name_hashes[] = PhabricatorHash::digestForIndex($name); | $name_hashes[] = PhabricatorHash::digestForIndex($name); | ||||
} | } | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.identityNameHash IN (%Ls)', | 'identity.identityNameHash IN (%Ls)', | ||||
$name_hashes); | $name_hashes); | ||||
} | } | ||||
if ($this->emailAddresses !== null) { | if ($this->emailAddresses !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.emailAddress IN (%Ls)', | 'identity.emailAddress IN (%Ls)', | ||||
$this->emailAddresses); | $this->emailAddresses); | ||||
} | } | ||||
if ($this->identityNameLike != null) { | if ($this->identityNameLike != null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'repository_identity.identityNameRaw LIKE %~', | 'identity.identityNameRaw LIKE %~', | ||||
$this->identityNameLike); | $this->identityNameLike); | ||||
} | } | ||||
if ($this->relatedPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'(identity.manuallySetUserPHID IN (%Ls) OR | |||||
identity.currentEffectiveUserPHID IN (%Ls) OR | |||||
identity.automaticGuessedUserPHID IN (%Ls))', | |||||
$this->relatedPHIDs, | |||||
$this->relatedPHIDs, | |||||
$this->relatedPHIDs); | |||||
} | |||||
return $where; | return $where; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorDiffusionApplication'; | return 'PhabricatorDiffusionApplication'; | ||||
} | } | ||||
} | } |