Path: blob/master/src/infrastructure/customfield/herald/PhabricatorCustomFieldHeraldField.php
12241 views
<?php12final class PhabricatorCustomFieldHeraldField extends HeraldField {34const FIELDCONST = 'herald.custom';56private $customField;78public function setCustomField(PhabricatorCustomField $custom_field) {9$this->customField = $custom_field;10return $this;11}1213public function getCustomField() {14return $this->customField;15}1617public function getFieldGroupKey() {18return PhabricatorCustomFieldHeraldFieldGroup::FIELDGROUPKEY;19}2021public function supportsObject($object) {22return ($object instanceof PhabricatorCustomFieldInterface);23}2425public function getFieldsForObject($object) {26$field_list = PhabricatorCustomField::getObjectFields(27$object,28PhabricatorCustomField::ROLE_HERALD);29$field_list->setViewer(PhabricatorUser::getOmnipotentUser());30$field_list->readFieldsFromStorage($object);3132$prefix = 'herald.custom/';33$limit = self::getFieldConstantByteLimit();3435$map = array();36foreach ($field_list->getFields() as $field) {37$key = $field->getFieldKey();3839// NOTE: This use of digestToLength() isn't preferred (you should40// normally digest a key unconditionally, so that it isn't possible to41// arrange a collision) but preserves backward compatibility.4243$full_key = $prefix.$key;44if (strlen($full_key) > $limit) {45$full_key = PhabricatorHash::digestToLength($full_key, $limit);46}4748$map[$full_key] = id(new PhabricatorCustomFieldHeraldField())49->setCustomField($field);50}5152return $map;53}5455public function getHeraldFieldName() {56return $this->getCustomField()->getHeraldFieldName();57}5859public function getHeraldFieldValue($object) {60return $this->getCustomField()->getHeraldFieldValue();61}6263public function getHeraldFieldConditions() {64return $this->getCustomField()->getHeraldFieldConditions();65}6667protected function getHeraldFieldStandardType() {68return $this->getCustomField()->getHeraldFieldStandardType();69}7071public function getHeraldFieldValueType($condition) {72if ($this->getHeraldFieldStandardType()) {73return parent::getHeraldFieldValueType($condition);74}7576return $this->getCustomField()->getHeraldFieldValueType($condition);77}7879protected function getDatasource() {80return $this->getCustomField()->getHeraldDatasource();81}8283}848586