Skip to content

Commit

Permalink
Add ImportTemplateField entity
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Dec 6, 2024
1 parent 62775c6 commit 734a3b9
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CRM/Core/DAO/ImportTemplateField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* Placeholder class retained for legacy compatibility.
*/
class CRM_Core_DAO_ImportTemplateField extends CRM_Core_DAO_Base {
}
2 changes: 2 additions & 0 deletions CRM/Utils/API/HTMLInputCoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public function getSkipFields() {
'items',
// Survey entity
'instructions',
// ImportTemplateField entity_data
'entity_data',
];
$custom = CRM_Core_DAO::executeQuery('
SELECT cf.id, cf.name AS field_name, cg.name AS group_name
Expand Down
25 changes: 25 additions & 0 deletions Civi/Api4/ImportTemplateField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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;

/**
* ImportTemplateField entity - stores field mappings for import templates.
*
* @see \Civi\Api4\UFGroup
* @orderBy column_number
* @groupWeightsBy user_job_id
* @since 5.82
* @package Civi\Api4
*/
class ImportTemplateField extends Generic\DAOEntity {
use Generic\Traits\SortableEntity;

}
71 changes: 71 additions & 0 deletions schema/Core/ImportTemplateField.entityType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

return [
'name' => 'ImportTemplateField',
'table' => 'civicrm_import_template_field',
'class' => 'CRM_Core_DAO_ImportTemplateField',
'getInfo' => fn() => [
'title' => ts('Import Template Field'),
'title_plural' => ts('Import Template Fields'),
'description' => ts('Individual field for an import template'),
'add' => '5.82',
],
'getFields' => fn() => [
'id' => [
'title' => ts('Field ID'),
'sql_type' => 'int unsigned',
'input_type' => 'Number',
'required' => TRUE,
'add' => '5.82',
'primary_key' => TRUE,
'auto_increment' => TRUE,
],
'user_job_id' => [
'title' => ts('Job ID'),
'sql_type' => 'int unsigned',
'input_type' => 'EntityRef',
'required' => TRUE,
'description' => ts('Template to which this field belongs'),
'add' => '5.82',
'input_attrs' => [
'label' => ts('Template'),
],
'entity_reference' => [
'entity' => 'UserJob',
'key' => 'id',
'on_delete' => 'CASCADE',
],
],
'name' => [
'title' => ts('Field Name'),
'sql_type' => 'varchar(1024)',
'input_type' => 'Text',
'description' => ts('Template field key'),
'add' => '5.82',
],
'column_number' => [
'title' => ts('Column Number to map to'),
'sql_type' => 'int unsigned',
'input_type' => 'Number',
'required' => TRUE,
'description' => ts('Column number for the import dataset'),
'add' => '5.82',
],
'default_value' => [
'title' => ts('Default Value'),
'sql_type' => 'varchar(1024)',
'input_type' => 'Text',
'description' => ts('SQL WHERE value for search-builder mapping fields.'),
'add' => '5.82',
],
'entity_data' => [
'title' => ts('Entity Data'),
'sql_type' => 'text',
'input_type' => 'TextArea',
'description' => ts('Configuration data for the field'),
'add' => '5.82',
'default' => NULL,
'serialize' => CRM_Core_DAO::SERIALIZE_JSON,
],
],
];

0 comments on commit 734a3b9

Please sign in to comment.