protected function ContentEntityNormalizer::cleanupData in Content Synchronization 3.0.x
Same name and namespace in other branches
- 8.2 src/Normalizer/ContentEntityNormalizer.php \Drupal\content_sync\Normalizer\ContentEntityNormalizer::cleanupData()
Parameters
$data:
$entity_type_id:
1 call to ContentEntityNormalizer::cleanupData()
- ContentEntityNormalizer::denormalize in src/
Normalizer/ ContentEntityNormalizer.php
File
- src/
Normalizer/ ContentEntityNormalizer.php, line 328
Class
- ContentEntityNormalizer
- Adds the file URI to embedded file entities.
Namespace
Drupal\content_sync\NormalizerCode
protected function cleanupData(&$data, $entity_type_id, $bundle = FALSE) {
if ($bundle) {
$field_definitions = $this->entityFieldManager
->getFieldDefinitions($entity_type_id, $bundle);
}
else {
$bundles = array_keys($this->entityTypeBundleInfo
->getBundleInfo($entity_type_id));
$field_definitions = [];
foreach ($bundles as $bundle) {
$field_definitions_bundle = $this->entityFieldManager
->getFieldDefinitions($entity_type_id, $bundle);
if (is_array($field_definitions_bundle)) {
$field_definitions += $field_definitions_bundle;
}
}
}
$field_names = array_keys($field_definitions);
foreach ($data as $field_name => $field_data) {
if (!in_array($field_name, $field_names)) {
unset($data[$field_name]);
}
}
}