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 $proxyPHIDs; | ||||
private $statuses; | private $statuses; | ||||
private $isProxyColumn; | private $isProxyColumn; | ||||
private $triggerPHIDs; | |||||
private $needTriggers; | |||||
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 15 Lines | public function withStatuses(array $status) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withIsProxyColumn($is_proxy) { | public function withIsProxyColumn($is_proxy) { | ||||
$this->isProxyColumn = $is_proxy; | $this->isProxyColumn = $is_proxy; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withTriggerPHIDs(array $trigger_phids) { | |||||
$this->triggerPHIDs = $trigger_phids; | |||||
return $this; | |||||
} | |||||
public function needTriggers($need_triggers) { | |||||
$this->needTriggers = true; | |||||
return $this; | |||||
} | |||||
public function newResultObject() { | public function newResultObject() { | ||||
return new PhabricatorProjectColumn(); | return new PhabricatorProjectColumn(); | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | return $this->loadStandardPage($this->newResultObject()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | foreach ($page as $key => $column) { | ||||
} | } | ||||
} else { | } else { | ||||
$proxy = null; | $proxy = null; | ||||
} | } | ||||
$column->attachProxy($proxy); | $column->attachProxy($proxy); | ||||
} | } | ||||
if ($this->needTriggers) { | |||||
$trigger_phids = array(); | |||||
foreach ($page as $column) { | |||||
if ($column->canHaveTrigger()) { | |||||
$trigger_phid = $column->getTriggerPHID(); | |||||
if ($trigger_phid) { | |||||
$trigger_phids[] = $trigger_phid; | |||||
} | |||||
} | |||||
} | |||||
if ($trigger_phids) { | |||||
$triggers = id(new PhabricatorProjectTriggerQuery()) | |||||
->setViewer($this->getViewer()) | |||||
->setParentQuery($this) | |||||
->withPHIDs(array($this->getPHID())) | |||||
->execute(); | |||||
$triggers = mpull($triggers, null, 'getPHID'); | |||||
} else { | |||||
$triggers = array(); | |||||
} | |||||
foreach ($page as $column) { | |||||
$trigger = null; | |||||
if ($column->canHaveTrigger()) { | |||||
$trigger_phid = $column->getTriggerPHID(); | |||||
if ($trigger_phid) { | |||||
$trigger = idx($triggers, $trigger_phid); | |||||
} | |||||
} | |||||
$column->attachTrigger($trigger); | |||||
} | |||||
} | |||||
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 25 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->statuses !== null) { | if ($this->statuses !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'status IN (%Ld)', | 'status IN (%Ld)', | ||||
$this->statuses); | $this->statuses); | ||||
} | } | ||||
if ($this->triggerPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'triggerPHID IN (%Ls)', | |||||
$this->triggerPHIDs); | |||||
} | |||||
if ($this->isProxyColumn !== null) { | if ($this->isProxyColumn !== null) { | ||||
if ($this->isProxyColumn) { | if ($this->isProxyColumn) { | ||||
$where[] = qsprintf($conn, 'proxyPHID IS NOT NULL'); | $where[] = qsprintf($conn, 'proxyPHID IS NOT NULL'); | ||||
} else { | } else { | ||||
$where[] = qsprintf($conn, 'proxyPHID IS NULL'); | $where[] = qsprintf($conn, 'proxyPHID IS NULL'); | ||||
} | } | ||||
} | } | ||||
return $where; | return $where; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorProjectApplication'; | return 'PhabricatorProjectApplication'; | ||||
} | } | ||||
} | } |