Path: blob/master/src/applications/calendar/query/PhabricatorCalendarImportLogQuery.php
12256 views
<?php12final class PhabricatorCalendarImportLogQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $phids;7private $importPHIDs;89public function withIDs(array $ids) {10$this->ids = $ids;11return $this;12}1314public function withPHIDs(array $phids) {15$this->phids = $phids;16return $this;17}1819public function withImportPHIDs(array $phids) {20$this->importPHIDs = $phids;21return $this;22}2324public function newResultObject() {25return new PhabricatorCalendarImportLog();26}2728protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {29$where = parent::buildWhereClauseParts($conn);3031if ($this->ids !== null) {32$where[] = qsprintf(33$conn,34'log.id IN (%Ld)',35$this->ids);36}3738if ($this->phids !== null) {39$where[] = qsprintf(40$conn,41'log.phid IN (%Ls)',42$this->phids);43}4445if ($this->importPHIDs !== null) {46$where[] = qsprintf(47$conn,48'log.importPHID IN (%Ls)',49$this->importPHIDs);50}515253return $where;54}5556protected function willFilterPage(array $page) {57$viewer = $this->getViewer();5859$type_map = PhabricatorCalendarImportLogType::getAllLogTypes();60foreach ($page as $log) {61$type_constant = $log->getParameter('type');6263$type_object = idx($type_map, $type_constant);64if (!$type_object) {65$type_object = new PhabricatorCalendarImportDefaultLogType();66}6768$type_object = clone $type_object;69$log->attachLogType($type_object);70}7172$import_phids = mpull($page, 'getImportPHID');7374if ($import_phids) {75$imports = id(new PhabricatorCalendarImportQuery())76->setViewer($viewer)77->withPHIDs($import_phids)78->execute();79$imports = mpull($imports, null, 'getPHID');80} else {81$imports = array();82}8384foreach ($page as $key => $log) {85$import = idx($imports, $log->getImportPHID());86if (!$import) {87$this->didRejectResult($import);88unset($page[$key]);89continue;90}9192$log->attachImport($import);93}9495return $page;96}9798protected function getPrimaryTableAlias() {99return 'log';100}101102public function getQueryApplicationClass() {103return 'PhabricatorCalendarApplication';104}105106}107108109