private function Mapper::setFieldsInCommon in Feeds Paragraphs 8
Finds fields that share the same host as the target.
Parameters
FieldDefinitionInterface $field: The target fields.
FieldDefinitionInterface[] $fields: The other collected fields so far.
1 call to Mapper::setFieldsInCommon()
- Mapper::getSubFields in src/
Mapper.php
File
- src/
Mapper.php, line 258
Class
Namespace
Drupal\feeds_para_mapperCode
private function setFieldsInCommon(FieldDefinitionInterface &$field, array &$fields) {
foreach ($fields as $key => $other_field) {
$other_info = $other_field
->get('target_info');
$last_key = count($other_info->path) - 1;
$others_host = $other_info->path[$last_key];
$info = $field
->get('target_info');
$current_host_key = count($info->path) - 1;
$current_host = $info->path[$current_host_key];
if ($others_host['host_field'] === $current_host['host_field']) {
if (!isset($info->in_common)) {
$info->in_common = array();
}
if (!isset($other_info->in_common)) {
$other_info->in_common = array();
}
$other_field_in_common = array(
'id' => $other_field
->id(),
'name' => $other_field
->getName(),
);
$field_in_common = array(
'id' => $field
->id(),
'name' => $field
->getName(),
);
$info->in_common[] = $other_field_in_common;
$field
->set('target_info', $info);
$other_info->in_common[] = $field_in_common;
$other_field
->set('target_info', $other_info);
}
}
}