Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / infrastructure / customfield / herald / PhabricatorCustomFieldHeraldField.php
blobb9e5724ef673f52cf736bb89ff1a2555433a7b7a
1 <?php
3 final class PhabricatorCustomFieldHeraldField extends HeraldField {
5 const FIELDCONST = 'herald.custom';
7 private $customField;
9 public function setCustomField(PhabricatorCustomField $custom_field) {
10 $this->customField = $custom_field;
11 return $this;
14 public function getCustomField() {
15 return $this->customField;
18 public function getFieldGroupKey() {
19 return PhabricatorCustomFieldHeraldFieldGroup::FIELDGROUPKEY;
22 public function supportsObject($object) {
23 return ($object instanceof PhabricatorCustomFieldInterface);
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);
33 $prefix = 'herald.custom/';
34 $limit = self::getFieldConstantByteLimit();
36 $map = array();
37 foreach ($field_list->getFields() as $field) {
38 $key = $field->getFieldKey();
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.
44 $full_key = $prefix.$key;
45 if (strlen($full_key) > $limit) {
46 $full_key = PhabricatorHash::digestToLength($full_key, $limit);
49 $map[$full_key] = id(new PhabricatorCustomFieldHeraldField())
50 ->setCustomField($field);
53 return $map;
56 public function getHeraldFieldName() {
57 return $this->getCustomField()->getHeraldFieldName();
60 public function getHeraldFieldValue($object) {
61 return $this->getCustomField()->getHeraldFieldValue();
64 public function getHeraldFieldConditions() {
65 return $this->getCustomField()->getHeraldFieldConditions();
68 protected function getHeraldFieldStandardType() {
69 return $this->getCustomField()->getHeraldFieldStandardType();
72 public function getHeraldFieldValueType($condition) {
73 if ($this->getHeraldFieldStandardType()) {
74 return parent::getHeraldFieldValueType($condition);
77 return $this->getCustomField()->getHeraldFieldValueType($condition);
80 protected function getDatasource() {
81 return $this->getCustomField()->getHeraldDatasource();