protected function DisplayFieldCopy::getFieldDefinition in Display Field Copy 2.x
Same name and namespace in other branches
- 8 src/Plugin/DsField/DisplayFieldCopy.php \Drupal\display_field_copy\Plugin\DsField\DisplayFieldCopy::getFieldDefinition()
Return the field definition.
1 call to DisplayFieldCopy::getFieldDefinition()
- DisplayFieldCopy::getFormatter in src/
Plugin/ DsField/ DisplayFieldCopy.php - Return the field formatter.
File
- src/
Plugin/ DsField/ DisplayFieldCopy.php, line 155
Class
- DisplayFieldCopy
- Defines a generic dynamic field that holds a copy of an exisitng core field.
Namespace
Drupal\display_field_copy\Plugin\DsFieldCode
protected function getFieldDefinition() {
if (!$this->fieldDefinition) {
$field_id = $this->pluginDefinition['properties']['field_id'];
$pieces = explode('.', $field_id);
$entity_type_id = $pieces[0];
if (count($pieces) == 3) {
$storage = $this->entityTypeManager
->getStorage('field_config');
$this->fieldDefinition = $storage
->load($field_id);
}
else {
$id = $pieces[1];
$this->fieldDefinition = $this->entityFieldManager
->getBaseFieldDefinitions($entity_type_id)[$id];
}
}
return $this->fieldDefinition;
}