Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
1a970586
Commit
1a970586
authored
3 weeks ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
Allow EntityPrefix to be passed to validateRequiredFields
parent
aa8c9e2c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Contact/Import/Parser/Contact.php
+2
-0
2 additions, 0 deletions
CRM/Contact/Import/Parser/Contact.php
CRM/Import/Parser.php
+10
-3
10 additions, 3 deletions
CRM/Import/Parser.php
with
12 additions
and
3 deletions
CRM/Contact/Import/Parser/Contact.php
+
2
−
0
View file @
1a970586
...
...
@@ -27,6 +27,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser {
private
$externalIdentifiers
=
[];
protected
$baseEntity
=
'Contact'
;
/**
* Relationship labels.
*
...
...
This diff is collapsed.
Click to expand it.
CRM/Import/Parser.php
+
10
−
3
View file @
1a970586
...
...
@@ -409,7 +409,7 @@ abstract class CRM_Import_Parser implements UserJobInterface {
// specified dedupe rule (or the default Unsupervised if not specified).
$requiredFields
=
$contactType
===
'Individual'
?
[[
$requiredFields
,
'external_identifier'
]]
:
[[
$requiredFields
,
'email'
,
'external_identifier'
]];
}
$this
->
validateRequiredFields
(
$requiredFields
,
$params
,
$prefixString
);
$this
->
validateRequiredFields
(
$requiredFields
,
$params
,
''
,
$prefixString
);
}
/**
...
...
@@ -677,11 +677,18 @@ abstract class CRM_Import_Parser implements UserJobInterface {
* ['first_name', 'last_name']
* ]
* Means 'email' OR 'first_name AND 'last_name'.
* @param string $entityName
* Entity name, if the entity is prefixed in the `getAvailableFields()` array
* - we are working towards this being required.
* @param string $prefixString
*
* @throws \CRM_Core_Exception Exception thrown if field requirements are not met.
*/
protected
function
validateRequiredFields
(
array
$requiredFields
,
array
$params
,
$prefixString
=
''
):
void
{
protected
function
validateRequiredFields
(
array
$requiredFields
,
array
$params
,
string
$entityName
=
''
,
string
$prefixString
=
''
):
void
{
if
(
$entityName
)
{
// @todo - make entityName required once all fields are prefixed.
$params
=
CRM_Utils_Array
::
prefixKeys
(
$params
,
"
$entityName
."
);
}
$missingFields
=
$this
->
getMissingFields
(
$requiredFields
,
$params
);
if
(
empty
(
$missingFields
))
{
return
;
...
...
@@ -1154,7 +1161,7 @@ abstract class CRM_Import_Parser implements UserJobInterface {
*/
protected
function
validateParams
(
array
$params
):
void
{
if
(
empty
(
$params
[
'id'
])
&&
empty
(
$params
[
$this
->
baseEntity
][
'id'
]))
{
$this
->
validateRequiredFields
(
$this
->
getRequiredFields
(),
$params
[
$this
->
baseEntity
]
??
$params
);
$this
->
validateRequiredFields
(
$this
->
getRequiredFields
(),
$params
[
$this
->
baseEntity
]
??
$params
,
$this
->
getImportEntities
()[
$this
->
baseEntity
][
'entity_field_prefix'
]
);
}
$errors
=
[];
foreach
(
$params
as
$key
=>
$value
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment