New structure for getFields array in `.entityType.php`
Currently getFields reads from a schema/xml
file with some wonky formatting. The plan in #4999 is to migrate those .xml
files to .entityType.php
files. So now we have a clean slate to decide how those files should be formatted.
Note: This will not affect the output of DAO::fields()
or APIv(3|4).getFields
, as we'll add a compatibility layer and tests to ensure those remain unchanged. But since we're replacing the underlying source of the data with something new, we get to clean that up.
Here are all the current keys in the schema/xml files, and what we plan to do with it in the new file. Many of the proposed changes would improve consistency with APIv4.getFields.
Old key from xml
|
What to do | New key in php
|
Notes |
---|---|---|---|
<name> |
|
Use name as array key, omit from array values | |
<title> |
|
title |
|
<required> |
|
required |
|
<add> |
|
add |
|
<pseudoconstant> |
|
pseudoconstant |
snake_case all values in array |
<default> |
|
default |
|
<contactType> |
|
contact_type |
|
<deprecated> |
|
deprecated |
|
<readonly> |
|
readonly |
|
<serialize> |
|
serialize |
|
<localizable> |
|
localizable |
|
<usage> |
|
usage |
|
<component> |
|
component |
Ok, but it smells bad to have columns belonging to one component in another component's table |
<localize_context> |
|
localize_context |
Obscure property only used by 3 fields, but it's easier to keep it. |
<type> |
|
sql_type |
|
<crmType> |
|
data_type |
Historically this was inferred by <type> but a few fields explicitly declare <crmType>
|
<uniqueName> |
|
unique_name |
We can't get rid of it yet but we can discourage it & stop indexing by it at every layer except DAO::fields()
|
<uniqueTitle> |
|
unique_title |
Are title & attributes[label] not enough? |
<comment> |
|
description |
|
<html> |
|
attributes |
type gets moved out (see <html><type> below), while length gets moved in as maxlength
|
<html><type> |
|
input_type |
|
<length> |
|
attributes[maxlength] |
That seems better. |
<import> |
|
usage[import] |
|
<export> |
|
usage[export] |
|
<foreignKey> |
|
entity_reference |
This tag is outside of <fields> in the xml but doesn't need to be. Let's move it into the getFields array. |
<dynamicForeignKey> |
|
entity_reference |
Conceptually the same as above so can share the same name. |
<permission> |
|
permission |
Convert <or> tags to nested array format used by CRM_Core_Permisison::check() . |
<drop> |
|
<drop> designates a field has been dropped, but in that case let's just remove it from the array as nothing else was being done with it. |
|
<rule> |
|
Unused as of PR#29611. | |
<headerPattern> |
|
Unused as of PR#29612. | |
<dataPattern> |
|
Appears to be unused in universe . |
|
<fulltext/> |
|
Apparently unused. Ignored by GenCode when writing DAOs. |