Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / almanac / query / AlmanacNamespaceQuery.php
blobe6c99bf6ead02fb596906a92fdbad4467a6c10e3
1 <?php
3 final class AlmanacNamespaceQuery
4 extends AlmanacQuery {
6 private $ids;
7 private $phids;
8 private $names;
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 withNames(array $names) {
21 $this->names = $names;
22 return $this;
25 public function withNameNgrams($ngrams) {
26 return $this->withNgramsConstraint(
27 new AlmanacNamespaceNameNgrams(),
28 $ngrams);
31 public function newResultObject() {
32 return new AlmanacNamespace();
35 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
36 $where = parent::buildWhereClauseParts($conn);
38 if ($this->ids !== null) {
39 $where[] = qsprintf(
40 $conn,
41 'namespace.id IN (%Ld)',
42 $this->ids);
45 if ($this->phids !== null) {
46 $where[] = qsprintf(
47 $conn,
48 'namespace.phid IN (%Ls)',
49 $this->phids);
52 if ($this->names !== null) {
53 $where[] = qsprintf(
54 $conn,
55 'namespace.name IN (%Ls)',
56 $this->names);
59 return $where;
62 protected function getPrimaryTableAlias() {
63 return 'namespace';
66 public function getOrderableColumns() {
67 return parent::getOrderableColumns() + array(
68 'name' => array(
69 'table' => $this->getPrimaryTableAlias(),
70 'column' => 'name',
71 'type' => 'string',
72 'unique' => true,
73 'reverse' => true,
78 protected function newPagingMapFromPartialObject($object) {
79 return array(
80 'id' => (int)$object->getID(),
81 'name' => $object->getName(),
85 public function getBuiltinOrders() {
86 return array(
87 'name' => array(
88 'vector' => array('name'),
89 'name' => pht('Namespace Name'),
91 ) + parent::getBuiltinOrders();
94 public function getQueryApplicationClass() {
95 return 'PhabricatorAlmanacApplication';