[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/almanac/query/ -> AlmanacQuery.php (source)

   1  <?php
   2  
   3  abstract class AlmanacQuery
   4    extends PhabricatorCursorPagedPolicyAwareQuery {
   5  
   6    protected function didFilterPage(array $objects) {
   7      if (head($objects) instanceof AlmanacPropertyInterface) {
   8        // NOTE: We load properties unconditionally because CustomField assumes
   9        // it can always generate a list of fields on an object. It may make
  10        // sense to re-examine that assumption eventually.
  11  
  12        $property_query = id(new AlmanacPropertyQuery())
  13          ->setViewer($this->getViewer())
  14          ->setParentQuery($this)
  15          ->withObjectPHIDs(mpull($objects, null, 'getPHID'));
  16  
  17        // NOTE: We disable policy filtering and object attachment to avoid
  18        // a cyclic dependency where objects need their properties and properties
  19        // need their objects. We'll attach the objects below, and have already
  20        // implicitly checked the necessary policies.
  21        $property_query->setDisablePolicyFilteringAndAttachment(true);
  22  
  23        $properties = $property_query->execute();
  24        $properties = mgroup($properties, 'getObjectPHID');
  25        foreach ($objects as $object) {
  26          $object_properties = idx($properties, $object->getPHID(), array());
  27          foreach ($object_properties as $property) {
  28            $property->attachObject($object);
  29          }
  30          $object->attachAlmanacProperties($object_properties);
  31        }
  32      }
  33  
  34      return $objects;
  35    }
  36  
  37    public function getQueryApplicationClass() {
  38      return 'PhabricatorAlmanacApplication';
  39    }
  40  
  41  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1