Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / infrastructure / customfield / standard / PhabricatorStandardCustomFieldLink.php
blob146f34ab0705096fa80d132bb292a02542a156cf
1 <?php
3 final class PhabricatorStandardCustomFieldLink
4 extends PhabricatorStandardCustomField {
6 public function getFieldType() {
7 return 'link';
10 public function buildFieldIndexes() {
11 $indexes = array();
13 $value = $this->getFieldValue();
14 if (strlen($value)) {
15 $indexes[] = $this->newStringIndex($value);
18 return $indexes;
21 public function renderPropertyViewValue(array $handles) {
22 $value = $this->getFieldValue();
24 if (!strlen($value)) {
25 return null;
28 if (!PhabricatorEnv::isValidRemoteURIForLink($value)) {
29 return $value;
32 return phutil_tag(
33 'a',
34 array(
35 'href' => $value,
36 'target' => '_blank',
37 'rel' => 'noreferrer',
39 $value);
42 public function readApplicationSearchValueFromRequest(
43 PhabricatorApplicationSearchEngine $engine,
44 AphrontRequest $request) {
46 return $request->getStr($this->getFieldKey());
49 public function applyApplicationSearchConstraintToQuery(
50 PhabricatorApplicationSearchEngine $engine,
51 PhabricatorCursorPagedPolicyAwareQuery $query,
52 $value) {
54 if (is_string($value) && !strlen($value)) {
55 return;
58 $value = (array)$value;
59 if ($value) {
60 $query->withApplicationSearchContainsConstraint(
61 $this->newStringIndex(null),
62 $value);
66 public function appendToApplicationSearchForm(
67 PhabricatorApplicationSearchEngine $engine,
68 AphrontFormView $form,
69 $value) {
71 $form->appendChild(
72 id(new AphrontFormTextControl())
73 ->setLabel($this->getFieldName())
74 ->setName($this->getFieldKey())
75 ->setValue($value));
78 public function shouldAppearInHerald() {
79 return true;
82 public function getHeraldFieldConditions() {
83 return array(
84 HeraldAdapter::CONDITION_CONTAINS,
85 HeraldAdapter::CONDITION_NOT_CONTAINS,
86 HeraldAdapter::CONDITION_IS,
87 HeraldAdapter::CONDITION_IS_NOT,
88 HeraldAdapter::CONDITION_REGEXP,
89 HeraldAdapter::CONDITION_NOT_REGEXP,
93 public function getHeraldFieldStandardType() {
94 return HeraldField::STANDARD_TEXT;
97 protected function getHTTPParameterType() {
98 return new AphrontStringHTTPParameterType();
101 protected function newConduitSearchParameterType() {
102 return new ConduitStringListParameterType();
105 protected function newConduitEditParameterType() {
106 return new ConduitStringParameterType();