Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#5634 Add ImportTemplateField entity #31580

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
],
],
];