3 final class AlmanacPropertyQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
11 public function withIDs(array $ids) {
16 public function withObjectPHIDs(array $phids) {
17 $this->objectPHIDs
= $phids;
21 public function withObjects(array $objects) {
22 $this->objects
= mpull($objects, null, 'getPHID');
23 $this->objectPHIDs
= array_keys($this->objects
);
27 public function withNames(array $names) {
28 $this->names
= $names;
32 public function newResultObject() {
33 return new AlmanacProperty();
36 protected function loadPage() {
37 return $this->loadStandardPage($this->newResultObject());
40 protected function willFilterPage(array $properties) {
41 $object_phids = mpull($properties, 'getObjectPHID');
43 $object_phids = array_fuse($object_phids);
45 if ($this->objects
!== null) {
46 $object_phids = array_diff_key($object_phids, $this->objects
);
50 $objects = id(new PhabricatorObjectQuery())
51 ->setViewer($this->getViewer())
52 ->setParentQuery($this)
53 ->withPHIDs($object_phids)
55 $objects = mpull($objects, null, 'getPHID');
60 $objects +
= $this->objects
;
62 foreach ($properties as $key => $property) {
63 $object = idx($objects, $property->getObjectPHID());
65 unset($properties[$key]);
68 $property->attachObject($object);
74 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
75 $where = parent
::buildWhereClauseParts($conn);
77 if ($this->ids
!== null) {
84 if ($this->objectPHIDs
!== null) {
87 'objectPHID IN (%Ls)',
91 if ($this->names
!== null) {
93 foreach ($this->names
as $name) {
94 $hashes[] = PhabricatorHash
::digestForIndex($name);
98 'fieldIndex IN (%Ls)',
105 public function getQueryApplicationClass() {
106 return 'PhabricatorAlmanacApplication';