Path: blob/master/src/applications/almanac/query/AlmanacQuery.php
12256 views
<?php12abstract class AlmanacQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $needProperties;67public function needProperties($need_properties) {8$this->needProperties = $need_properties;9return $this;10}1112protected function getNeedProperties() {13return $this->needProperties;14}1516protected function didFilterPage(array $objects) {17$has_properties = (head($objects) instanceof AlmanacPropertyInterface);1819if ($has_properties && $this->needProperties) {20$property_query = id(new AlmanacPropertyQuery())21->setViewer($this->getViewer())22->setParentQuery($this)23->withObjects($objects);2425$properties = $property_query->execute();2627$properties = mgroup($properties, 'getObjectPHID');28foreach ($objects as $object) {29$object_properties = idx($properties, $object->getPHID(), array());30$object_properties = mpull($object_properties, null, 'getFieldName');3132// Create synthetic properties for defaults on the object itself.33$specs = $object->getAlmanacPropertyFieldSpecifications();34foreach ($specs as $key => $spec) {35if (empty($object_properties[$key])) {36$default_value = $spec->getValueForTransaction();3738$object_properties[$key] = id(new AlmanacProperty())39->setObjectPHID($object->getPHID())40->setFieldName($key)41->setFieldValue($default_value);42}43}4445foreach ($object_properties as $property) {46$property->attachObject($object);47}4849$object->attachAlmanacProperties($object_properties);50}51}5253return $objects;54}5556public function getQueryApplicationClass() {57return 'PhabricatorAlmanacApplication';58}5960}616263