Path: blob/master/src/applications/almanac/query/AlmanacPropertyQuery.php
12256 views
<?php12final class AlmanacPropertyQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $objectPHIDs;7private $objects;8private $names;910public function withIDs(array $ids) {11$this->ids = $ids;12return $this;13}1415public function withObjectPHIDs(array $phids) {16$this->objectPHIDs = $phids;17return $this;18}1920public function withObjects(array $objects) {21$this->objects = mpull($objects, null, 'getPHID');22$this->objectPHIDs = array_keys($this->objects);23return $this;24}2526public function withNames(array $names) {27$this->names = $names;28return $this;29}3031public function newResultObject() {32return new AlmanacProperty();33}3435protected function willFilterPage(array $properties) {36$object_phids = mpull($properties, 'getObjectPHID');3738$object_phids = array_fuse($object_phids);3940if ($this->objects !== null) {41$object_phids = array_diff_key($object_phids, $this->objects);42}4344if ($object_phids) {45$objects = id(new PhabricatorObjectQuery())46->setViewer($this->getViewer())47->setParentQuery($this)48->withPHIDs($object_phids)49->execute();50$objects = mpull($objects, null, 'getPHID');51} else {52$objects = array();53}5455$objects += $this->objects;5657foreach ($properties as $key => $property) {58$object = idx($objects, $property->getObjectPHID());59if (!$object) {60unset($properties[$key]);61continue;62}63$property->attachObject($object);64}6566return $properties;67}6869protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {70$where = parent::buildWhereClauseParts($conn);7172if ($this->ids !== null) {73$where[] = qsprintf(74$conn,75'id IN (%Ld)',76$this->ids);77}7879if ($this->objectPHIDs !== null) {80$where[] = qsprintf(81$conn,82'objectPHID IN (%Ls)',83$this->objectPHIDs);84}8586if ($this->names !== null) {87$hashes = array();88foreach ($this->names as $name) {89$hashes[] = PhabricatorHash::digestForIndex($name);90}91$where[] = qsprintf(92$conn,93'fieldIndex IN (%Ls)',94$hashes);95}9697return $where;98}99100public function getQueryApplicationClass() {101return 'PhabricatorAlmanacApplication';102}103104}105106107