Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
5.6 kB · 234 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235<?php
/** * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorProjectColumn> */final class PhabricatorProjectColumnQuery extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids; private $phids; private $projectPHIDs; private $proxyPHIDs; private $statuses; private $isProxyColumn; private $triggerPHIDs; private $needTriggers;
public function withIDs(array $ids) { $this->ids = $ids; return $this; }
public function withPHIDs(array $phids) { $this->phids = $phids; return $this; }
public function withProjectPHIDs(array $project_phids) { $this->projectPHIDs = $project_phids; return $this; }
public function withProxyPHIDs(array $proxy_phids) { $this->proxyPHIDs = $proxy_phids; return $this; }
public function withStatuses(array $status) { $this->statuses = $status; return $this; }
public function withIsProxyColumn($is_proxy) { $this->isProxyColumn = $is_proxy; 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() { return new PhabricatorProjectColumn(); }
protected function willFilterPage(array $page) { $projects = array();
$project_phids = array_filter(mpull($page, 'getProjectPHID')); if ($project_phids) { $projects = id(new PhabricatorProjectQuery()) ->setParentQuery($this) ->setViewer($this->getViewer()) ->withPHIDs($project_phids) ->execute(); $projects = mpull($projects, null, 'getPHID'); }
foreach ($page as $key => $column) { $phid = $column->getProjectPHID(); $project = idx($projects, $phid); if (!$project) { $this->didRejectResult($page[$key]); unset($page[$key]); continue; } $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 surprised 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); }
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($trigger_phids) ->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; }
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); }
if ($this->phids !== null) { $where[] = qsprintf( $conn, 'phid IN (%Ls)', $this->phids); }
if ($this->projectPHIDs !== null) { $where[] = qsprintf( $conn, 'projectPHID IN (%Ls)', $this->projectPHIDs); }
if ($this->proxyPHIDs !== null) { $where[] = qsprintf( $conn, 'proxyPHID IN (%Ls)', $this->proxyPHIDs); }
if ($this->statuses !== null) { $where[] = qsprintf( $conn, 'status IN (%Ld)', $this->statuses); }
if ($this->triggerPHIDs !== null) { $where[] = qsprintf( $conn, 'triggerPHID IN (%Ls)', $this->triggerPHIDs); }
if ($this->isProxyColumn !== null) { if ($this->isProxyColumn) { $where[] = qsprintf($conn, 'proxyPHID IS NOT NULL'); } else { $where[] = qsprintf($conn, 'proxyPHID IS NULL'); } }
return $where; }
public function getQueryApplicationClass() { return PhabricatorProjectApplication::class; }
}