Add help_pre and help_post to api4 fieldSpec
authorColeman Watts <coleman@civicrm.org>
Tue, 12 Nov 2019 19:34:00 +0000 (14:34 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 12 Nov 2019 19:34:00 +0000 (14:34 -0500)
Civi/Api4/Generic/DAOGetFieldsAction.php
Civi/Api4/Service/Spec/FieldSpec.php
Civi/Api4/Service/Spec/SpecFormatter.php
Civi/Api4/Service/Spec/SpecGatherer.php

index 296d93c5d80189d4516ce96232762c8e069f0980..7f7402d49a47e558609727a12c06879aa57b2cee 100644 (file)
@@ -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',
index 3baaebed45ccf7bc254177b6df1e0267251c3dee..494d8aa818d345af29da18c7e26c91bda5e299d6 100644 (file)
@@ -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
    *
index 7b6108457844624870ae1d64ca4420092905211b..126794b848fb8b8cb217e9ddaf77aebd69319aba 100644 (file)
@@ -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);
index 94de36a5328b87aff19505c75df6b33ec98955ce..12c673af58691304661c5edf11a52ee251ae6869 100644 (file)
@@ -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) {