Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/customfield/herald/PhabricatorCustomFieldHeraldField.php
12241 views
1
<?php
2
3
final class PhabricatorCustomFieldHeraldField extends HeraldField {
4
5
const FIELDCONST = 'herald.custom';
6
7
private $customField;
8
9
public function setCustomField(PhabricatorCustomField $custom_field) {
10
$this->customField = $custom_field;
11
return $this;
12
}
13
14
public function getCustomField() {
15
return $this->customField;
16
}
17
18
public function getFieldGroupKey() {
19
return PhabricatorCustomFieldHeraldFieldGroup::FIELDGROUPKEY;
20
}
21
22
public function supportsObject($object) {
23
return ($object instanceof PhabricatorCustomFieldInterface);
24
}
25
26
public function getFieldsForObject($object) {
27
$field_list = PhabricatorCustomField::getObjectFields(
28
$object,
29
PhabricatorCustomField::ROLE_HERALD);
30
$field_list->setViewer(PhabricatorUser::getOmnipotentUser());
31
$field_list->readFieldsFromStorage($object);
32
33
$prefix = 'herald.custom/';
34
$limit = self::getFieldConstantByteLimit();
35
36
$map = array();
37
foreach ($field_list->getFields() as $field) {
38
$key = $field->getFieldKey();
39
40
// NOTE: This use of digestToLength() isn't preferred (you should
41
// normally digest a key unconditionally, so that it isn't possible to
42
// arrange a collision) but preserves backward compatibility.
43
44
$full_key = $prefix.$key;
45
if (strlen($full_key) > $limit) {
46
$full_key = PhabricatorHash::digestToLength($full_key, $limit);
47
}
48
49
$map[$full_key] = id(new PhabricatorCustomFieldHeraldField())
50
->setCustomField($field);
51
}
52
53
return $map;
54
}
55
56
public function getHeraldFieldName() {
57
return $this->getCustomField()->getHeraldFieldName();
58
}
59
60
public function getHeraldFieldValue($object) {
61
return $this->getCustomField()->getHeraldFieldValue();
62
}
63
64
public function getHeraldFieldConditions() {
65
return $this->getCustomField()->getHeraldFieldConditions();
66
}
67
68
protected function getHeraldFieldStandardType() {
69
return $this->getCustomField()->getHeraldFieldStandardType();
70
}
71
72
public function getHeraldFieldValueType($condition) {
73
if ($this->getHeraldFieldStandardType()) {
74
return parent::getHeraldFieldValueType($condition);
75
}
76
77
return $this->getCustomField()->getHeraldFieldValueType($condition);
78
}
79
80
protected function getDatasource() {
81
return $this->getCustomField()->getHeraldDatasource();
82
}
83
84
}
85
86