self::getNextId(), 'version' => 3, 'params' => $params, 'fields' => NULL, 'entity' => self::normalizeEntityName($entity), 'action' => self::normalizeActionName($action), ]; case 4: // For custom pseudo-entities if (strpos($entity, 'Custom_') === 0) { $apiRequest = \Civi\Api4\CustomValue::$action(substr($entity, 7)); } else { $callable = ["\\Civi\\Api4\\$entity", $action]; if (!is_callable($callable)) { throw new \Civi\API\Exception\NotImplementedException("API ($entity, $action) does not exist (join the API team and implement it!)"); } $apiRequest = call_user_func($callable); } foreach ($params as $name => $param) { $setter = 'set' . ucfirst($name); $apiRequest->$setter($param); } return $apiRequest; default: throw new \Civi\API\Exception\NotImplementedException("Unknown api version"); } } /** * Normalize entity to be CamelCase. * * APIv1-v3 munges entity/action names, and accepts any mixture of case and underscores. * * @param string $entity * @return string */ public static function normalizeEntityName($entity) { return \CRM_Core_DAO_AllCoreTables::convertEntityNameToCamel(\CRM_Utils_String::munge($entity), TRUE); } /** * Normalize api action name to be lowercase. * * APIv1-v3 munges entity/action names, and accepts any mixture of case and underscores. * * @param $action * @param $version * @return string */ public static function normalizeActionName($action) { return strtolower(\CRM_Utils_String::munge($action)); } public static function getNextId() { return self::$nextId++; } }