$fns[] = [
'name' => $className::getName(),
'params' => $className::getParams(),
+ 'category' => $className::getCategory(),
];
}
}
protected $args = [];
+ /**
+ * Used for categorizing functions in the UI
+ *
+ * @var string
+ */
+ protected static $category;
+
+ const CATEGORY_AGGREGATE = 'aggregate',
+ CATEGORY_COMPARISON = 'comparison',
+ CATEGORY_DATE = 'date',
+ CATEGORY_MATH = 'math',
+ CATEGORY_STRING = 'string';
+
/**
* Parse the argument string into an array of function arguments
*/
return $params;
}
+ /**
+ * @return string
+ */
+ public static function getCategory(): string {
+ return static::$category;
+ }
+
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionABS extends SqlFunction {
+
+ protected static $category = self::CATEGORY_MATH;
+
+ protected static $params = [
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlNumber'],
+ ],
+ ];
+
+}
*/
class SqlFunctionAVG extends SqlFunction {
+ protected static $category = self::CATEGORY_AGGREGATE;
+
protected static $params = [
[
'prefix' => ['', 'DISTINCT', 'ALL'],
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionCOALESCE extends SqlFunction {
+
+ protected static $category = self::CATEGORY_COMPARISON;
+
+ protected static $params = [
+ [
+ 'expr' => 99,
+ 'optional' => FALSE,
+ ],
+ ];
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionCONCAT extends SqlFunction {
+
+ protected static $category = self::CATEGORY_STRING;
+
+ protected static $params = [
+ [
+ 'expr' => 99,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlString'],
+ ],
+ ];
+
+}
*/
class SqlFunctionCOUNT extends SqlFunction {
+ protected static $category = self::CATEGORY_AGGREGATE;
+
protected static $params = [
[
'prefix' => ['', 'DISTINCT', 'ALL'],
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionCURDATE extends SqlFunction {
+
+ protected static $category = self::CATEGORY_DATE;
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionGREATEST extends SqlFunction {
+
+ protected static $category = self::CATEGORY_COMPARISON;
+
+ protected static $params = [
+ [
+ 'expr' => 99,
+ 'optional' => FALSE,
+ ],
+ ];
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionGROUP_CONCAT extends SqlFunction {
+
+ protected static $category = self::CATEGORY_AGGREGATE;
+
+ protected static $params = [
+ [
+ 'prefix' => ['', 'DISTINCT', 'ALL'],
+ 'expr' => 1,
+ 'must_be' => ['SqlField'],
+ 'optional' => FALSE,
+ ],
+ [
+ 'prefix' => ['ORDER BY'],
+ 'expr' => 1,
+ 'suffix' => ['', 'ASC', 'DESC'],
+ 'must_be' => ['SqlField'],
+ 'optional' => TRUE,
+ ],
+ [
+ 'prefix' => ['SEPARATOR'],
+ 'expr' => 1,
+ 'must_be' => ['SqlString'],
+ 'optional' => TRUE,
+ ],
+ ];
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionISNULL extends SqlFunction {
+
+ protected static $category = self::CATEGORY_COMPARISON;
+
+ protected static $params = [
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ ],
+ ];
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionLEAST extends SqlFunction {
+
+ protected static $category = self::CATEGORY_COMPARISON;
+
+ protected static $params = [
+ [
+ 'expr' => 99,
+ 'optional' => FALSE,
+ ],
+ ];
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionLOWER extends SqlFunction {
+
+ protected static $category = self::CATEGORY_STRING;
+
+ protected static $params = [
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlString'],
+ ],
+ ];
+
+}
*/
class SqlFunctionMAX extends SqlFunction {
+ protected static $category = self::CATEGORY_AGGREGATE;
+
protected static $params = [
[
'prefix' => ['', 'DISTINCT', 'ALL'],
*/
class SqlFunctionMIN extends SqlFunction {
+ protected static $category = self::CATEGORY_AGGREGATE;
+
protected static $params = [
[
'prefix' => ['', 'DISTINCT', 'ALL'],
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionNULLIF extends SqlFunction {
+
+ protected static $category = self::CATEGORY_COMPARISON;
+
+ protected static $params = [
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ ],
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ ],
+ ];
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionREPLACE extends SqlFunction {
+
+ protected static $category = self::CATEGORY_STRING;
+
+ protected static $params = [
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlString'],
+ ],
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlString'],
+ ],
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlString'],
+ ],
+ ];
+
+}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionROUND extends SqlFunction {
+
+ protected static $category = self::CATEGORY_MATH;
+
+ protected static $params = [
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlNumber'],
+ ],
+ [
+ 'expr' => 1,
+ 'optional' => TRUE,
+ 'must_be' => ['SqlNumber'],
+ ],
+ ];
+
+}
*/
class SqlFunctionSUM extends SqlFunction {
+ protected static $category = self::CATEGORY_AGGREGATE;
+
protected static $params = [
[
'prefix' => ['', 'DISTINCT', 'ALL'],
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Query;
+
+/**
+ * Sql function
+ */
+class SqlFunctionUPPER extends SqlFunction {
+
+ protected static $category = self::CATEGORY_STRING;
+
+ protected static $params = [
+ [
+ 'expr' => 1,
+ 'optional' => FALSE,
+ 'must_be' => ['SqlField', 'SqlString'],
+ ],
+ ];
+
+}