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 willFilterPage(array $properties) {
37 $object_phids = mpull($properties, 'getObjectPHID');
39 $object_phids = array_fuse($object_phids);
41 if ($this->objects
!== null) {
42 $object_phids = array_diff_key($object_phids, $this->objects
);
46 $objects = id(new PhabricatorObjectQuery())
47 ->setViewer($this->getViewer())
48 ->setParentQuery($this)
49 ->withPHIDs($object_phids)
51 $objects = mpull($objects, null, 'getPHID');
56 $objects +
= $this->objects
;
58 foreach ($properties as $key => $property) {
59 $object = idx($objects, $property->getObjectPHID());
61 unset($properties[$key]);
64 $property->attachObject($object);
70 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
71 $where = parent
::buildWhereClauseParts($conn);
73 if ($this->ids
!== null) {
80 if ($this->objectPHIDs
!== null) {
83 'objectPHID IN (%Ls)',
87 if ($this->names
!== null) {
89 foreach ($this->names
as $name) {
90 $hashes[] = PhabricatorHash
::digestForIndex($name);
94 'fieldIndex IN (%Ls)',
101 public function getQueryApplicationClass() {
102 return 'PhabricatorAlmanacApplication';