From: Coleman Watts <coleman@civicrm.org> Date: Tue, 12 Nov 2019 19:34:00 +0000 (-0500) Subject: Add help_pre and help_post to api4 fieldSpec X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f274627b2d8876edaa68441c9965d2ce75737cd9;p=civicrm-core.git Add help_pre and help_post to api4 fieldSpec --- diff --git a/Civi/Api4/Generic/DAOGetFieldsAction.php b/Civi/Api4/Generic/DAOGetFieldsAction.php index 296d93c5d8..7f7402d49a 100644 --- a/Civi/Api4/Generic/DAOGetFieldsAction.php +++ b/Civi/Api4/Generic/DAOGetFieldsAction.php @@ -73,6 +73,14 @@ class DAOGetFieldsAction extends BasicGetFieldsAction { public function fields() { $fields = parent::fields(); + $fields[] = [ + 'name' => 'help_pre', + 'data_type' => 'String', + ]; + $fields[] = [ + 'name' => 'help_post', + 'data_type' => 'String', + ]; $fields[] = [ 'name' => 'custom_field_id', 'data_type' => 'Integer', diff --git a/Civi/Api4/Service/Spec/FieldSpec.php b/Civi/Api4/Service/Spec/FieldSpec.php index 3baaebed45..494d8aa818 100644 --- a/Civi/Api4/Service/Spec/FieldSpec.php +++ b/Civi/Api4/Service/Spec/FieldSpec.php @@ -105,6 +105,16 @@ class FieldSpec { */ protected $serialize; + /** + * @var string + */ + protected $helpPre; + + /** + * @var string + */ + protected $helpPost; + /** * Aliases for the valid data types * @@ -320,6 +330,34 @@ class FieldSpec { return $this; } + /** + * @return string|NULL + */ + public function getHelpPre() { + return $this->helpPre; + } + + /** + * @param string|NULL $helpPre + */ + public function setHelpPre($helpPre) { + $this->helpPre = is_string($helpPre) && strlen($helpPre) ? $helpPre : NULL; + } + + /** + * @return string|NULL + */ + public function getHelpPost() { + return $this->helpPost; + } + + /** + * @param string|NULL $helpPost + */ + public function setHelpPost($helpPost) { + $this->helpPost = is_string($helpPost) && strlen($helpPost) ? $helpPost : NULL; + } + /** * Add valid types that are not not part of \CRM_Utils_Type::dataTypes * diff --git a/Civi/Api4/Service/Spec/SpecFormatter.php b/Civi/Api4/Service/Spec/SpecFormatter.php index 7b61084578..126794b848 100644 --- a/Civi/Api4/Service/Spec/SpecFormatter.php +++ b/Civi/Api4/Service/Spec/SpecFormatter.php @@ -82,6 +82,8 @@ class SpecFormatter { $field->setCustomFieldId(ArrayHelper::value('id', $data)); $field->setCustomGroupName($data['custom_group.name']); $field->setTitle(ArrayHelper::value('label', $data)); + $field->setHelpPre(ArrayHelper::value('help_pre', $data)); + $field->setHelpPost(ArrayHelper::value('help_post', $data)); $field->setOptions(self::customFieldHasOptions($data)); if (\CRM_Core_BAO_CustomField::isSerialized($data)) { $field->setSerialize(\CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND); diff --git a/Civi/Api4/Service/Spec/SpecGatherer.php b/Civi/Api4/Service/Spec/SpecGatherer.php index 94de36a532..12c673af58 100644 --- a/Civi/Api4/Service/Spec/SpecGatherer.php +++ b/Civi/Api4/Service/Spec/SpecGatherer.php @@ -136,7 +136,7 @@ class SpecGatherer { $customFields = CustomField::get() ->setCheckPermissions(FALSE) ->addWhere('custom_group.extends', 'IN', $extends) - ->setSelect(['custom_group.name', 'custom_group_id', 'name', 'label', 'data_type', 'html_type', 'is_searchable', 'is_search_range', 'weight', 'is_active', 'is_view', 'option_group_id', 'default_value', 'date_format', 'time_format', 'start_date_years', 'end_date_years']) + ->setSelect(['custom_group.name', 'custom_group_id', 'name', 'label', 'data_type', 'html_type', 'is_searchable', 'is_search_range', 'weight', 'is_active', 'is_view', 'option_group_id', 'default_value', 'date_format', 'time_format', 'start_date_years', 'end_date_years', 'help_pre', 'help_post']) ->execute(); foreach ($customFields as $fieldArray) { @@ -152,7 +152,7 @@ class SpecGatherer { private function getCustomGroupFields($customGroup, RequestSpec $specification) { $customFields = CustomField::get() ->addWhere('custom_group.name', '=', $customGroup) - ->setSelect(['custom_group.name', 'custom_group_id', 'name', 'label', 'data_type', 'html_type', 'is_searchable', 'is_search_range', 'weight', 'is_active', 'is_view', 'option_group_id', 'default_value', 'custom_group.table_name', 'column_name', 'date_format', 'time_format', 'start_date_years', 'end_date_years']) + ->setSelect(['custom_group.name', 'custom_group_id', 'name', 'label', 'data_type', 'html_type', 'is_searchable', 'is_search_range', 'weight', 'is_active', 'is_view', 'option_group_id', 'default_value', 'custom_group.table_name', 'column_name', 'date_format', 'time_format', 'start_date_years', 'end_date_years', 'help_pre', 'help_post']) ->execute(); foreach ($customFields as $fieldArray) {