@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 110 lines 2.4 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorCalendarImportLog> 5 */ 6final class PhabricatorCalendarImportLogQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $importPHIDs; 12 13 public function withIDs(array $ids) { 14 $this->ids = $ids; 15 return $this; 16 } 17 18 public function withPHIDs(array $phids) { 19 $this->phids = $phids; 20 return $this; 21 } 22 23 public function withImportPHIDs(array $phids) { 24 $this->importPHIDs = $phids; 25 return $this; 26 } 27 28 public function newResultObject() { 29 return new PhabricatorCalendarImportLog(); 30 } 31 32 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 33 $where = parent::buildWhereClauseParts($conn); 34 35 if ($this->ids !== null) { 36 $where[] = qsprintf( 37 $conn, 38 'log.id IN (%Ld)', 39 $this->ids); 40 } 41 42 if ($this->phids !== null) { 43 $where[] = qsprintf( 44 $conn, 45 'log.phid IN (%Ls)', 46 $this->phids); 47 } 48 49 if ($this->importPHIDs !== null) { 50 $where[] = qsprintf( 51 $conn, 52 'log.importPHID IN (%Ls)', 53 $this->importPHIDs); 54 } 55 56 57 return $where; 58 } 59 60 protected function willFilterPage(array $page) { 61 $viewer = $this->getViewer(); 62 63 $type_map = PhabricatorCalendarImportLogType::getAllLogTypes(); 64 foreach ($page as $log) { 65 $type_constant = $log->getParameter('type'); 66 67 $type_object = idx($type_map, $type_constant); 68 if (!$type_object) { 69 $type_object = new PhabricatorCalendarImportDefaultLogType(); 70 } 71 72 $type_object = clone $type_object; 73 $log->attachLogType($type_object); 74 } 75 76 $import_phids = mpull($page, 'getImportPHID'); 77 78 if ($import_phids) { 79 $imports = id(new PhabricatorCalendarImportQuery()) 80 ->setViewer($viewer) 81 ->withPHIDs($import_phids) 82 ->execute(); 83 $imports = mpull($imports, null, 'getPHID'); 84 } else { 85 $imports = array(); 86 } 87 88 foreach ($page as $key => $log) { 89 $import = idx($imports, $log->getImportPHID()); 90 if (!$import) { 91 $this->didRejectResult($import); 92 unset($page[$key]); 93 continue; 94 } 95 96 $log->attachImport($import); 97 } 98 99 return $page; 100 } 101 102 protected function getPrimaryTableAlias() { 103 return 'log'; 104 } 105 106 public function getQueryApplicationClass() { 107 return PhabricatorCalendarApplication::class; 108 } 109 110}