Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / phlux / query / PhluxVariableQuery.php
blob8ec4bc93342025c0773390e42a513d1f5f50df64
1 <?php
3 final class PhluxVariableQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $keys;
8 private $phids;
10 public function withIDs(array $ids) {
11 $this->ids = $ids;
12 return $this;
15 public function withPHIDs(array $phids) {
16 $this->phids = $phids;
17 return $this;
20 public function withKeys(array $keys) {
21 $this->keys = $keys;
22 return $this;
25 protected function loadPage() {
26 $table = new PhluxVariable();
27 $conn_r = $table->establishConnection('r');
29 $rows = queryfx_all(
30 $conn_r,
31 'SELECT * FROM %T %Q %Q %Q',
32 $table->getTableName(),
33 $this->buildWhereClause($conn_r),
34 $this->buildOrderClause($conn_r),
35 $this->buildLimitClause($conn_r));
37 return $table->loadAllFromArray($rows);
40 protected function buildWhereClause(AphrontDatabaseConnection $conn) {
41 $where = array();
43 if ($this->ids !== null) {
44 $where[] = qsprintf(
45 $conn,
46 'id IN (%Ld)',
47 $this->ids);
50 if ($this->keys !== null) {
51 $where[] = qsprintf(
52 $conn,
53 'variableKey IN (%Ls)',
54 $this->keys);
57 if ($this->phids !== null) {
58 $where[] = qsprintf(
59 $conn,
60 'phid IN (%Ls)',
61 $this->phids);
64 $where[] = $this->buildPagingClause($conn);
66 return $this->formatWhereClause($conn, $where);
69 protected function getDefaultOrderVector() {
70 return array('key');
73 public function getOrderableColumns() {
74 return array(
75 'key' => array(
76 'column' => 'variableKey',
77 'type' => 'string',
78 'reverse' => true,
79 'unique' => true,
84 protected function newPagingMapFromPartialObject($object) {
85 return array(
86 'id' => (int)$object->getID(),
87 'key' => $object->getVariableKey(),
91 public function getQueryApplicationClass() {
92 return 'PhabricatorPhluxApplication';