Add CONCAT_WS fn to APIv4 and UI support in SearchKit
[civicrm-core.git] / Civi / Api4 / Query / SqlFunctionCOALESCE.php
index 324d62fecf761c4ded7078729b54111141ab6281..5264e04ef1432beeb220bed94daf4db6860eab86 100644 (file)
@@ -18,12 +18,20 @@ class SqlFunctionCOALESCE extends SqlFunction {
 
   protected static $category = self::CATEGORY_COMPARISON;
 
-  protected static $params = [
-    [
-      'max_expr' => 99,
-      'optional' => FALSE,
-    ],
-  ];
+  protected static $dataType = 'String';
+
+  protected static function params(): array {
+    return [
+      [
+        'max_expr' => 99,
+        'optional' => FALSE,
+        'ui_defaults' => [
+          ['type' => 'SqlField', 'placeholder' => ts('If')],
+          ['type' => 'SqlField', 'placeholder' => ts('Else')],
+        ],
+      ],
+    ];
+  }
 
   /**
    * @return string
@@ -33,16 +41,10 @@ class SqlFunctionCOALESCE extends SqlFunction {
   }
 
   /**
-   * Prevent reformatting
-   *
-   * @see \Civi\Api4\Utils\FormattingUtil::formatOutputValues
-   * @param string $value
-   * @param string $dataType
-   * @return string|array
+   * @return string
    */
-  public function formatOutputValue($value, &$dataType) {
-    $dataType = NULL;
-    return $value;
+  public static function getDescription(): string {
+    return ts('The first value that is not null.');
   }
 
 }