Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/query/PhabricatorProjectColumnQuery.php
<?php | <?php | ||||
final class PhabricatorProjectColumnQuery | final class PhabricatorProjectColumnQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $projectPHIDs; | private $projectPHIDs; | ||||
private $proxyPHIDs; | |||||
private $statuses; | private $statuses; | ||||
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; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withProjectPHIDs(array $project_phids) { | public function withProjectPHIDs(array $project_phids) { | ||||
$this->projectPHIDs = $project_phids; | $this->projectPHIDs = $project_phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withProxyPHIDs(array $proxy_phids) { | |||||
$this->proxyPHIDs = $proxy_phids; | |||||
return $this; | |||||
} | |||||
public function withStatuses(array $status) { | public function withStatuses(array $status) { | ||||
$this->statuses = $status; | $this->statuses = $status; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function newResultObject() { | public function newResultObject() { | ||||
return new PhabricatorProjectColumn(); | return new PhabricatorProjectColumn(); | ||||
} | } | ||||
Show All 21 Lines | foreach ($page as $key => $column) { | ||||
if (!$project) { | if (!$project) { | ||||
$this->didRejectResult($page[$key]); | $this->didRejectResult($page[$key]); | ||||
unset($page[$key]); | unset($page[$key]); | ||||
continue; | continue; | ||||
} | } | ||||
$column->attachProject($project); | $column->attachProject($project); | ||||
} | } | ||||
$proxy_phids = array_filter(mpull($page, 'getProjectPHID')); | |||||
return $page; | |||||
} | |||||
protected function didFilterPage(array $page) { | |||||
$proxy_phids = array(); | |||||
foreach ($page as $column) { | |||||
$proxy_phid = $column->getProxyPHID(); | |||||
if ($proxy_phid !== null) { | |||||
$proxy_phids[$proxy_phid] = $proxy_phid; | |||||
} | |||||
} | |||||
if ($proxy_phids) { | |||||
$proxies = id(new PhabricatorObjectQuery()) | |||||
->setParentQuery($this) | |||||
->setViewer($this->getViewer()) | |||||
->withPHIDs($proxy_phids) | |||||
->execute(); | |||||
$proxies = mpull($proxies, null, 'getPHID'); | |||||
} else { | |||||
$proxies = array(); | |||||
} | |||||
foreach ($page as $key => $column) { | |||||
$proxy_phid = $column->getProxyPHID(); | |||||
if ($proxy_phid !== null) { | |||||
$proxy = idx($proxies, $proxy_phid); | |||||
// Only attach valid proxies, so we don't end up getting surprsied if | |||||
// an install somehow gets junk into their database. | |||||
if (!($proxy instanceof PhabricatorColumnProxyInterface)) { | |||||
$proxy = null; | |||||
} | |||||
if (!$proxy) { | |||||
$this->didRejectResult($column); | |||||
unset($page[$key]); | |||||
continue; | |||||
} | |||||
} else { | |||||
$proxy = null; | |||||
} | |||||
$column->attachProxy($proxy); | |||||
} | |||||
return $page; | return $page; | ||||
} | } | ||||
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( | ||||
Show All 11 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->projectPHIDs !== null) { | if ($this->projectPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'projectPHID IN (%Ls)', | 'projectPHID IN (%Ls)', | ||||
$this->projectPHIDs); | $this->projectPHIDs); | ||||
} | } | ||||
if ($this->proxyPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'proxyPHID IN (%Ls)', | |||||
$this->proxyPHIDs); | |||||
} | |||||
if ($this->statuses !== null) { | if ($this->statuses !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'status IN (%Ld)', | 'status IN (%Ld)', | ||||
$this->statuses); | $this->statuses); | ||||
} | } | ||||
return $where; | return $where; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorProjectApplication'; | return 'PhabricatorProjectApplication'; | ||||
} | } | ||||
} | } |