mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 09:22:40 +01:00
1491269b72
Summary: Ref T9252. Move these to the more modern stuff to pick up ordering and interface support for free. Also work around the blueprint / custom field integration a little more gracefully. Test Plan: Searched for blueprints, resources and leases. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9252 Differential Revision: https://secure.phabricator.com/D14155
88 lines
1.9 KiB
PHP
88 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class DrydockBlueprintQuery extends DrydockQuery {
|
|
|
|
private $ids;
|
|
private $phids;
|
|
private $blueprintClasses;
|
|
private $datasourceQuery;
|
|
|
|
public function withIDs(array $ids) {
|
|
$this->ids = $ids;
|
|
return $this;
|
|
}
|
|
|
|
public function withPHIDs(array $phids) {
|
|
$this->phids = $phids;
|
|
return $this;
|
|
}
|
|
|
|
public function withBlueprintClasses(array $classes) {
|
|
$this->blueprintClasses = $classes;
|
|
return $this;
|
|
}
|
|
|
|
public function withDatasourceQuery($query) {
|
|
$this->datasourceQuery = $query;
|
|
return $this;
|
|
}
|
|
|
|
public function newResultObject() {
|
|
return new DrydockBlueprint();
|
|
}
|
|
|
|
protected function loadPage() {
|
|
return $this->loadStandardPage($this->newResultObject());
|
|
}
|
|
|
|
protected function willFilterPage(array $blueprints) {
|
|
$impls = DrydockBlueprintImplementation::getAllBlueprintImplementations();
|
|
foreach ($blueprints as $key => $blueprint) {
|
|
$impl = idx($impls, $blueprint->getClassName());
|
|
if (!$impl) {
|
|
$this->didRejectResult($blueprint);
|
|
unset($blueprints[$key]);
|
|
continue;
|
|
}
|
|
$impl = clone $impl;
|
|
$blueprint->attachImplementation($impl);
|
|
}
|
|
|
|
return $blueprints;
|
|
}
|
|
|
|
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->datasourceQuery !== null) {
|
|
$where[] = qsprintf(
|
|
$conn,
|
|
'blueprintName LIKE %>',
|
|
$this->datasourceQuery);
|
|
}
|
|
|
|
if ($this->blueprintClasses !== null) {
|
|
$where[] = qsprintf(
|
|
$conn,
|
|
'className IN (%Ls)',
|
|
$this->blueprintClasses);
|
|
}
|
|
|
|
return $where;
|
|
}
|
|
|
|
}
|