Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/query/PhabricatorProjectColumnQuery.php
Show All 22 Lines | public function withProjectPHIDs(array $project_phids) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withStatuses(array $status) { | public function withStatuses(array $status) { | ||||
$this->statuses = $status; | $this->statuses = $status; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function loadPage() { | public function newResultObject() { | ||||
$table = new PhabricatorProjectColumn(); | return new PhabricatorProjectColumn(); | ||||
$conn_r = $table->establishConnection('r'); | } | ||||
$data = queryfx_all( | |||||
$conn_r, | |||||
'SELECT * FROM %T %Q %Q %Q', | |||||
$table->getTableName(), | |||||
$this->buildWhereClause($conn_r), | |||||
$this->buildOrderClause($conn_r), | |||||
$this->buildLimitClause($conn_r)); | |||||
return $table->loadAllFromArray($data); | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | |||||
} | } | ||||
protected function willFilterPage(array $page) { | protected function willFilterPage(array $page) { | ||||
$projects = array(); | $projects = array(); | ||||
$project_phids = array_filter(mpull($page, 'getProjectPHID')); | $project_phids = array_filter(mpull($page, 'getProjectPHID')); | ||||
if ($project_phids) { | if ($project_phids) { | ||||
$projects = id(new PhabricatorProjectQuery()) | $projects = id(new PhabricatorProjectQuery()) | ||||
->setParentQuery($this) | ->setParentQuery($this) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs($project_phids) | ->withPHIDs($project_phids) | ||||
->execute(); | ->execute(); | ||||
$projects = mpull($projects, null, 'getPHID'); | $projects = mpull($projects, null, 'getPHID'); | ||||
} | } | ||||
foreach ($page as $key => $column) { | foreach ($page as $key => $column) { | ||||
$phid = $column->getProjectPHID(); | $phid = $column->getProjectPHID(); | ||||
$project = idx($projects, $phid); | $project = idx($projects, $phid); | ||||
if (!$project) { | if (!$project) { | ||||
$this->didRejectResult($page[$key]); | |||||
unset($page[$key]); | unset($page[$key]); | ||||
continue; | continue; | ||||
} | } | ||||
$column->attachProject($project); | $column->attachProject($project); | ||||
} | } | ||||
return $page; | return $page; | ||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = array(); | $where = parent::buildWhereClauseParts($conn); | ||||
if ($this->ids) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'id IN (%Ld)', | 'id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'phid IN (%Ls)', | 'phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->projectPHIDs) { | if ($this->projectPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'projectPHID IN (%Ls)', | 'projectPHID IN (%Ls)', | ||||
$this->projectPHIDs); | $this->projectPHIDs); | ||||
} | } | ||||
if ($this->statuses !== null) { | if ($this->statuses !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'status IN (%Ld)', | 'status IN (%Ld)', | ||||
$this->statuses); | $this->statuses); | ||||
} | } | ||||
$where[] = $this->buildPagingClause($conn_r); | return $where; | ||||
return $this->formatWhereClause($where); | |||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorProjectApplication'; | return 'PhabricatorProjectApplication'; | ||||
} | } | ||||
} | } |