-
Notifications
You must be signed in to change notification settings - Fork 340
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
Refactoring mapping field building and merging with config files. #1055
Refactoring mapping field building and merging with config files. #1055
Conversation
I also refactored the Unit tests for Mapping since it does not rely anymore on Dynamic Fields Provider : easier to test now. But the Indices Config part remains untested about DynamicFieldProviders. let me know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See both comments.
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think it is a mistake to create a new getter for the config.
I would prefer a method mergeConfig(array $config) that would return a new instance of the field with updated config.
It is also possible to add a test on the mergeConfig method in FieldTest.
} | ||
|
||
foreach ($typeConfigData['mapping']['staticFields'] as $fieldName => $fieldConfig) { | ||
if (isset($fields[$fieldName])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use mergeConfig method instead of this one :
$field = $this->mappingFieldFactory->create(['name' => $fieldName] + $fieldConfig);
if (isset($fields[$fieldName]) {
$field = $fields[$fieldName]->mergeConfig($fieldConfig);
}
$fields[$fieldName] = $field;
7c5192e
to
33994f7
Compare
d421ed5
to
68d2029
Compare
PR updated and rebased |
Several things here :
Mapping class refactored to allow only an array of fields in constructor.
Fields are built by the Indices Config prior to creating the mapping.
Fields that exist both in a "dynamic provider" and from the elasticsuite_indices.xml file are now properly merged.
I made the choice to give precedence to the file : only some fieldConfig is written to the file, meaning it will only overwrite some values of the dynamically computed Field.
For SKU, this allow to have the "defaultSearchAnalyzer" defined in the file, and to rely on the Back-Office for Search Weight of the attribute.
Fix #920