protected function ExtraFieldTypePluginBase::getEntityTokenData in Entity Extra Field 8
Same name and namespace in other branches
- 2.0.x src/ExtraFieldTypePluginBase.php \Drupal\entity_extra_field\ExtraFieldTypePluginBase::getEntityTokenData()
Get entity token data.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The content entity instance.
Return value
array An array of token data.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to ExtraFieldTypePluginBase::getEntityTokenData()
- ExtraFieldTypePluginBase::processEntityToken in src/
ExtraFieldTypePluginBase.php - Process the entity token text.
File
- src/
ExtraFieldTypePluginBase.php, line 313
Class
- ExtraFieldTypePluginBase
- Define extra field type plugin base.
Namespace
Drupal\entity_extra_fieldCode
protected function getEntityTokenData(ContentEntityInterface $entity) {
$field_references = $this
->getEntityFieldReferenceTypes($entity
->getEntityTypeId(), $entity
->bundle());
$data[$entity
->getEntityTypeId()] = $entity;
foreach ($field_references as $field_name => $target_type) {
if (!$entity
->hasField($field_name) || isset($data[$target_type])) {
continue;
}
$data[$target_type] = $entity->{$field_name}->entity;
}
return array_filter($data);
}