Skip to content
Snippets Groups Projects
Unverified Commit f0f67f22 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #20501 from JMAConsulting/api4_batch_spec

Add APIv4 Batch.create spec
parents f96e4983 4c35651e
Branches 5.65
Tags 5.65.2
No related merge requests found
<?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 |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
namespace Civi\Api4\Service\Spec\Provider;
use Civi\Api4\Service\Spec\RequestSpec;
class BatchCreationSpecProvider implements Generic\SpecProviderInterface {
/**
* @inheritDoc
*/
public function modifySpec(RequestSpec $spec) {
$spec->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';
}
}
......@@ -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';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment