protected function MigrationDefinitionCreator::setDefinitionFieldProperties in GatherContent 8.5
Set the field process and destination properties.
1 call to MigrationDefinitionCreator::setDefinitionFieldProperties()
- MigrationDefinitionCreator::buildMigrationDefinition in src/
MigrationDefinitionCreator.php - Builds the migration definition.
File
- src/
MigrationDefinitionCreator.php, line 393
Class
- MigrationDefinitionCreator
- Create dynamic migration definitions.
Namespace
Drupal\gathercontentCode
protected function setDefinitionFieldProperties(array &$definition, array $data, EntityTypeInterface $entityDefinition) {
$labelSet = FALSE;
foreach ($data['elements'] as $elementId => $element) {
if (!$element) {
continue;
}
$elementKeys = explode('||', $element, 2);
$targetFieldInfo = NULL;
/** @var \Drupal\field\Entity\FieldConfig $fieldInfo */
$fieldInfo = FieldConfig::load($elementKeys[0]);
$fieldType = 'string';
$isTranslatable = TRUE;
$isMultiple = FALSE;
if (!empty($fieldInfo)) {
$fieldType = $fieldInfo
->getType();
$isTranslatable = $fieldInfo
->isTranslatable();
$isMultiple = $fieldInfo
->getFieldStorageDefinition()
->isMultiple();
}
$element = $this
->getElementLastPart($elementKeys[0]);
if ($element == $entityDefinition
->getKey('label') || $entityDefinition
->getKey('label') === FALSE) {
$labelSet = TRUE;
}
if (!empty($elementKeys[1])) {
$data['elements'][$elementId] = $elementKeys[1];
$subElementKeys = explode('||', $elementKeys[1]);
$targetFieldInfo = FieldConfig::load($subElementKeys[0]);
}
$definition['source']['fields'][] = $elementId;
$this
->setFieldDefinition($definition, $data, $elementId, $element, $fieldInfo, $fieldType, $targetFieldInfo, $isTranslatable, $isMultiple);
}
if (!$labelSet) {
$definition['source']['fields'][] = 'item_title';
$definition['process'][$entityDefinition
->getKey('label')] = 'item_title';
}
if (!empty($data['metatag_elements']) && $this->moduleHandler
->moduleExists('metatag') && $this->metatagQuery
->checkMetatag($this->mapping
->getMappedEntityType(), $this->mapping
->getContentType())) {
$metatagField = $this->metatagQuery
->getFirstMetatagField($this->mapping
->getMappedEntityType(), $this->mapping
->getContentType());
$definition['source']['fields'][] = 'meta_tags';
$definition['process'][$metatagField] = 'meta_tags';
}
}