Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/query/PhabricatorFileQuery.php
Show All 14 Lines | final class PhabricatorFileQuery | ||||
private $maxLength; | private $maxLength; | ||||
private $names; | private $names; | ||||
private $isPartial; | private $isPartial; | ||||
private $isDeleted; | private $isDeleted; | ||||
private $needTransforms; | private $needTransforms; | ||||
private $builtinKeys; | private $builtinKeys; | ||||
private $isBuiltin; | private $isBuiltin; | ||||
private $storageEngines; | private $storageEngines; | ||||
private $attachedObjectPHIDs; | |||||
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 25 Lines | public function withBuiltinKeys(array $keys) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withIsBuiltin($is_builtin) { | public function withIsBuiltin($is_builtin) { | ||||
$this->isBuiltin = $is_builtin; | $this->isBuiltin = $is_builtin; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withAttachedObjectPHIDs(array $phids) { | |||||
$this->attachedObjectPHIDs = $phids; | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* Select files which are transformations of some other file. For example, | * Select files which are transformations of some other file. For example, | ||||
* you can use this query to find previously generated thumbnails of an image | * you can use this query to find previously generated thumbnails of an image | ||||
* file. | * file. | ||||
* | * | ||||
* As a parameter, provide a list of transformation specifications. Each | * As a parameter, provide a list of transformation specifications. Each | ||||
* specification is a dictionary with the keys `originalPHID` and `transform`. | * specification is a dictionary with the keys `originalPHID` and `transform`. | ||||
* The `originalPHID` is the PHID of the original file (the file which was | * The `originalPHID` is the PHID of the original file (the file which was | ||||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->transforms) { | if ($this->transforms) { | ||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn, | $conn, | ||||
'JOIN %T t ON t.transformedPHID = f.phid', | 'JOIN %T t ON t.transformedPHID = f.phid', | ||||
id(new PhabricatorTransformedFile())->getTableName()); | id(new PhabricatorTransformedFile())->getTableName()); | ||||
} | } | ||||
if ($this->shouldJoinAttachmentsTable()) { | |||||
$joins[] = qsprintf( | |||||
$conn, | |||||
'JOIN %R attachments ON attachments.filePHID = f.phid', | |||||
new PhabricatorFileAttachment()); | |||||
} | |||||
return $joins; | return $joins; | ||||
} | } | ||||
private function shouldJoinAttachmentsTable() { | |||||
return ($this->attachedObjectPHIDs !== null); | |||||
} | |||||
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( | ||||
$conn, | $conn, | ||||
'f.id IN (%Ld)', | 'f.id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->storageEngines !== null) { | if ($this->storageEngines !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'storageEngine IN (%Ls)', | 'storageEngine IN (%Ls)', | ||||
$this->storageEngines); | $this->storageEngines); | ||||
} | } | ||||
if ($this->attachedObjectPHIDs !== null) { | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'attachments.objectPHID IN (%Ls)', | |||||
$this->attachedObjectPHIDs); | |||||
} | |||||
return $where; | return $where; | ||||
} | } | ||||
protected function getPrimaryTableAlias() { | protected function getPrimaryTableAlias() { | ||||
return 'f'; | return 'f'; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorFilesApplication'; | return 'PhabricatorFilesApplication'; | ||||
} | } | ||||
} | } |