Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / calendar / query / PhabricatorCalendarImportLogQuery.php
blob731b1209ccce5cd56435d83c7d7700fd918b3ef6
1 <?php
3 final class PhabricatorCalendarImportLogQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $phids;
8 private $importPHIDs;
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 withImportPHIDs(array $phids) {
21 $this->importPHIDs = $phids;
22 return $this;
25 public function newResultObject() {
26 return new PhabricatorCalendarImportLog();
29 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
30 $where = parent::buildWhereClauseParts($conn);
32 if ($this->ids !== null) {
33 $where[] = qsprintf(
34 $conn,
35 'log.id IN (%Ld)',
36 $this->ids);
39 if ($this->phids !== null) {
40 $where[] = qsprintf(
41 $conn,
42 'log.phid IN (%Ls)',
43 $this->phids);
46 if ($this->importPHIDs !== null) {
47 $where[] = qsprintf(
48 $conn,
49 'log.importPHID IN (%Ls)',
50 $this->importPHIDs);
54 return $where;
57 protected function willFilterPage(array $page) {
58 $viewer = $this->getViewer();
60 $type_map = PhabricatorCalendarImportLogType::getAllLogTypes();
61 foreach ($page as $log) {
62 $type_constant = $log->getParameter('type');
64 $type_object = idx($type_map, $type_constant);
65 if (!$type_object) {
66 $type_object = new PhabricatorCalendarImportDefaultLogType();
69 $type_object = clone $type_object;
70 $log->attachLogType($type_object);
73 $import_phids = mpull($page, 'getImportPHID');
75 if ($import_phids) {
76 $imports = id(new PhabricatorCalendarImportQuery())
77 ->setViewer($viewer)
78 ->withPHIDs($import_phids)
79 ->execute();
80 $imports = mpull($imports, null, 'getPHID');
81 } else {
82 $imports = array();
85 foreach ($page as $key => $log) {
86 $import = idx($imports, $log->getImportPHID());
87 if (!$import) {
88 $this->didRejectResult($import);
89 unset($page[$key]);
90 continue;
93 $log->attachImport($import);
96 return $page;
99 protected function getPrimaryTableAlias() {
100 return 'log';
103 public function getQueryApplicationClass() {
104 return 'PhabricatorCalendarApplication';