/** * Get the FieldDefinition object required to render this field's formatter. * * @return \Drupal\Core\Field\BaseFieldDefinition * The field definition. * * @see \Drupal\entity_embed\FieldFormatterEntityEmbedDisplayBase::build() */ public function getFieldDefinition() { if (!isset($this->fieldDefinition)) { $field_type = $this->getPluginDefinition()['field_type']; $this->fieldDefinition = BaseFieldDefinition::create($field_type); // Ensure the field name is unique for each Entity Embed Display plugin // instance. static $index = 0; $this->fieldDefinition->setName('_entity_embed_' . $index++); } return $this->fieldDefinition; }