Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / calendar / query / PhabricatorCalendarImportQuery.php
blob0e3dbbf38704d6b78f17f88d42fdb7cafb571aa9
1 <?php
3 final class PhabricatorCalendarImportQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $phids;
8 private $authorPHIDs;
9 private $isDisabled;
11 public function withIDs(array $ids) {
12 $this->ids = $ids;
13 return $this;
16 public function withPHIDs(array $phids) {
17 $this->phids = $phids;
18 return $this;
21 public function withAuthorPHIDs(array $phids) {
22 $this->authorPHIDs = $phids;
23 return $this;
26 public function withIsDisabled($is_disabled) {
27 $this->isDisabled = $is_disabled;
28 return $this;
31 public function newResultObject() {
32 return new PhabricatorCalendarImport();
35 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
36 $where = parent::buildWhereClauseParts($conn);
38 if ($this->ids !== null) {
39 $where[] = qsprintf(
40 $conn,
41 'import.id IN (%Ld)',
42 $this->ids);
45 if ($this->phids !== null) {
46 $where[] = qsprintf(
47 $conn,
48 'import.phid IN (%Ls)',
49 $this->phids);
52 if ($this->authorPHIDs !== null) {
53 $where[] = qsprintf(
54 $conn,
55 'import.authorPHID IN (%Ls)',
56 $this->authorPHIDs);
59 if ($this->isDisabled !== null) {
60 $where[] = qsprintf(
61 $conn,
62 'import.isDisabled = %d',
63 (int)$this->isDisabled);
66 return $where;
69 protected function willFilterPage(array $page) {
70 $engines = PhabricatorCalendarImportEngine::getAllImportEngines();
71 foreach ($page as $key => $import) {
72 $engine_type = $import->getEngineType();
73 $engine = idx($engines, $engine_type);
75 if (!$engine) {
76 unset($page[$key]);
77 $this->didRejectResult($import);
78 continue;
81 $import->attachEngine(clone $engine);
84 return $page;
87 protected function getPrimaryTableAlias() {
88 return 'import';
91 public function getQueryApplicationClass() {
92 return 'PhabricatorCalendarApplication';