APIv4 - Add "localizable" to getFields metadata
authorColeman Watts <coleman@civicrm.org>
Wed, 12 Apr 2023 16:29:25 +0000 (12:29 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 13 Apr 2023 01:16:27 +0000 (21:16 -0400)
Civi/Api4/Generic/BasicGetFieldsAction.php
Civi/Api4/Service/Spec/SpecFormatter.php
Civi/Schema/Traits/GuiSpecTrait.php

index 82dd6e0e5f57419a6141703dd75d9f0731ddbb6e..26780be1ee0e3a3b6cb0fbc363a1d22bcd5307fe 100644 (file)
@@ -346,6 +346,11 @@ class BasicGetFieldsAction extends BasicGetAction {
         'name' => 'entity',
         'data_type' => 'String',
       ],
+      [
+        'name' => 'localizable',
+        'data_type' => 'Boolean',
+        'default_value' => FALSE,
+      ],
       [
         'name' => 'readonly',
         'data_type' => 'Boolean',
index fc99a65e7928443734cadce614faf4e4d3ee5a24..1e83d8f5790d2ae27791216f1aef9cddf0f23579 100644 (file)
@@ -66,6 +66,7 @@ class SpecFormatter {
       $field->setRequired(!empty($data['required']) && empty($data['default']));
       $field->setTitle($data['title'] ?? NULL);
       $field->setLabel($data['html']['label'] ?? NULL);
+      $field->setLocalizable($data['localizable'] ?? FALSE);
       if (!empty($data['pseudoconstant'])) {
         // Do not load options if 'prefetch' is explicitly FALSE
         if (!isset($data['pseudoconstant']['prefetch']) || $data['pseudoconstant']['prefetch'] === FALSE) {
index 1a084f8fc249f3be5f8249df1e936fe885c86e17..888c71d2aec5f4fbdd9df8f1f33a5cefab5addca 100644 (file)
@@ -37,6 +37,13 @@ trait GuiSpecTrait {
    */
   public $inputType;
 
+  /**
+   * Can the field be translated.
+   *
+   * @var bool
+   */
+  public $localizable = FALSE;
+
   /**
    * @var array
    */
@@ -93,6 +100,23 @@ trait GuiSpecTrait {
     return $this;
   }
 
+  /**
+   * @return bool
+   */
+  public function getLocalizable() {
+    return $this->localizable;
+  }
+
+  /**
+   * @param bool $localizable
+   *
+   * @return $this
+   */
+  public function setLocalizable(bool $localizable) {
+    $this->localizable = $localizable;
+    return $this;
+  }
+
   /**
    * @param string $label
    *