Differential D17445 Diff 41957 src/applications/transactions/query/PhabricatorEditEngineConfigurationQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/query/PhabricatorEditEngineConfigurationQuery.php
<?php | <?php | ||||
final class PhabricatorEditEngineConfigurationQuery | final class PhabricatorEditEngineConfigurationQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $engineKeys; | private $engineKeys; | ||||
private $builtinKeys; | private $builtinKeys; | ||||
private $identifiers; | private $identifiers; | ||||
private $default; | private $default; | ||||
private $isEdit; | private $isEdit; | ||||
private $disabled; | private $disabled; | ||||
private $ignoreDatabaseConfigurations; | private $ignoreDatabaseConfigurations; | ||||
private $subtypes; | |||||
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 30 Lines | public function withIsDisabled($disabled) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withIgnoreDatabaseConfigurations($ignore) { | public function withIgnoreDatabaseConfigurations($ignore) { | ||||
$this->ignoreDatabaseConfigurations = $ignore; | $this->ignoreDatabaseConfigurations = $ignore; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withSubtypes(array $subtypes) { | |||||
$this->subtypes = $subtypes; | |||||
return $this; | |||||
} | |||||
public function newResultObject() { | public function newResultObject() { | ||||
return new PhabricatorEditEngineConfiguration(); | return new PhabricatorEditEngineConfiguration(); | ||||
} | } | ||||
protected function loadPage() { | protected function loadPage() { | ||||
// TODO: The logic here is a little flimsy and won't survive pagination. | // TODO: The logic here is a little flimsy and won't survive pagination. | ||||
// For now, I'm just not bothering with pagination since I believe it will | // For now, I'm just not bothering with pagination since I believe it will | ||||
// take some time before any install manages to produce a large enough | // take some time before any install manages to produce a large enough | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if ($this->identifiers !== null) { | ||||
} | } | ||||
if (isset($identifiers[$config->getID()])) { | if (isset($identifiers[$config->getID()])) { | ||||
continue; | continue; | ||||
} | } | ||||
unset($page[$key]); | unset($page[$key]); | ||||
} | } | ||||
} | } | ||||
if ($this->subtypes !== null) { | |||||
$subtypes = array_fuse($this->subtypes); | |||||
foreach ($page as $key => $config) { | |||||
if (isset($subtypes[$config->getSubtype()])) { | |||||
continue; | |||||
} | |||||
unset($page[$key]); | |||||
} | |||||
} | |||||
return $page; | return $page; | ||||
} | } | ||||
protected function willFilterPage(array $configs) { | protected function willFilterPage(array $configs) { | ||||
$engine_keys = mpull($configs, 'getEngineKey'); | $engine_keys = mpull($configs, 'getEngineKey'); | ||||
$engines = id(new PhabricatorEditEngineQuery()) | $engines = id(new PhabricatorEditEngineQuery()) | ||||
->setParentQuery($this) | ->setParentQuery($this) | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->identifiers !== null) { | if ($this->identifiers !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'(id IN (%Ls) OR builtinKey IN (%Ls))', | '(id IN (%Ls) OR builtinKey IN (%Ls))', | ||||
$this->identifiers, | $this->identifiers, | ||||
$this->identifiers); | $this->identifiers); | ||||
} | } | ||||
if ($this->subtypes !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'subtype IN (%Ls)', | |||||
$this->subtypes); | |||||
} | |||||
return $where; | return $where; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorTransactionsApplication'; | return 'PhabricatorTransactionsApplication'; | ||||
} | } | ||||
} | } |