protected function ContentProcessor::processDefaultField in GatherContent 8.4
Default processing function, when no other matches found, usually for text.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: Object of node.
\Drupal\field\Entity\FieldConfig $field_info: Local field Info object.
bool $is_translatable: Indicator if node is translatable.
string $language: Language of translation if applicable.
object $field: Object with field attributes.
string $text_format: Text format string.
string $parent_field_type: Parent field type string to pass through field type in case of reference fields.
1 call to ContentProcessor::processDefaultField()
- ContentProcessor::processContentPane in src/
Import/ ContentProcess/ ContentProcessor.php - Processing function for content panes.
File
- src/
Import/ ContentProcess/ ContentProcessor.php, line 420
Class
- ContentProcessor
- The ContentProcessor sets the necessary fields of the entity.
Namespace
Drupal\gathercontent\Import\ContentProcessCode
protected function processDefaultField(EntityInterface &$entity, FieldConfig $field_info, $is_translatable, $language, $field, $text_format, $parent_field_type = '') {
$local_field_name = $field_info
->getName();
$value = $field->value;
$target =& $entity;
if ($is_translatable) {
$target = $entity
->getTranslation($language);
}
switch ($field_info
->getType()) {
case 'datetime':
$value = strtotime($value);
if ($value === FALSE) {
// If we failed to convert to a timestamp, abort.
return;
}
$target->{$local_field_name} = [
'value' => gmdate(DATETIME_DATETIME_STORAGE_FORMAT, $value),
];
break;
case 'date':
$value = strtotime($value);
if ($value === FALSE) {
return;
}
$target->{$local_field_name} = [
'value' => gmdate(DATETIME_DATE_STORAGE_FORMAT, $value),
];
break;
default:
$id = $language . $field_info
->id();
if (!isset($this->concatFieldValues[$id]) || $parent_field_type === 'entity_reference_revisions') {
$this->concatFieldValues[$id] = '';
}
$this->concatFieldValues[$id] .= $value;
// Probably some kind of text field.
$target->{$local_field_name} = [
'value' => $this->concatFieldValues[$id],
'format' => isset($field->plainText) && $field->plainText ? 'plain_text' : (!empty($text_format) ? $text_format : 'basic_html'),
];
break;
}
}