From 4c35651e77f27cdf9f99dfd1174ff6db6aed9cb4 Mon Sep 17 00:00:00 2001 From: Monish Deb Date: Fri, 4 Jun 2021 12:42:08 +0530 Subject: [PATCH] Add APIv4 Batch.create spec --- .../Provider/BatchCreationSpecProvider.php | 43 +++++++++++++++++++ api/v3/Batch.php | 5 --- 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Civi/Api4/Service/Spec/Provider/BatchCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/BatchCreationSpecProvider.php b/Civi/Api4/Service/Spec/Provider/BatchCreationSpecProvider.php new file mode 100644 index 0000000000..d45ae81e50 --- /dev/null +++ b/Civi/Api4/Service/Spec/Provider/BatchCreationSpecProvider.php @@ -0,0 +1,43 @@ +getFieldByName('created_id')->setDefaultValue('user_contact_id'); + $spec->getFieldByName('created_date')->setDefaultValue('now'); + $spec->getFieldByName('modified_id')->setDefaultValue('user_contact_id'); + $spec->getFieldByName('modified_date')->setDefaultValue('now'); + } + + /** + * @inheritDoc + */ + public function applies($entity, $action) { + return $entity === 'Batch' && $action === 'create'; + } + +} diff --git a/api/v3/Batch.php b/api/v3/Batch.php index 8eedd82429..0b68afe415 100644 --- a/api/v3/Batch.php +++ b/api/v3/Batch.php @@ -37,11 +37,6 @@ function civicrm_api3_batch_create($params) { * Array of parameters determined by getfields. */ function _civicrm_api3_batch_create_spec(&$params) { - //@todo - the entity table field looks like it is not actually required & should probably be removed (or a description added if - // it is actually required) - $params['entity_table']['api.default'] = "civicrm_batch"; - $params['entity_table']['type'] = CRM_Utils_Type::T_STRING; - $params['entity_table']['title'] = 'Batch Entity Table - remove?'; $params['created_id']['api.default'] = 'user_contact_id'; $params['created_date']['api.default'] = 'now'; $params['modified_id']['api.default'] = 'user_contact_id'; -- 2.25.1