protected function ExtraFieldTypePluginBase::getEntityFieldReferenceTypes in Entity Extra Field 8
Same name and namespace in other branches
- 2.0.x src/ExtraFieldTypePluginBase.php \Drupal\entity_extra_field\ExtraFieldTypePluginBase::getEntityFieldReferenceTypes()
Get entity field reference types.
Parameters
$entity_type_id: The entity type identifier.
$entity_bundle: The entity bundle name.
Return value
array An array of reference types.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to ExtraFieldTypePluginBase::getEntityFieldReferenceTypes()
- ExtraFieldTypePluginBase::getEntityTokenData in src/
ExtraFieldTypePluginBase.php - Get entity token data.
- ExtraFieldTypePluginBase::getEntityTokenTypes in src/
ExtraFieldTypePluginBase.php - Get entity token types.
File
- src/
ExtraFieldTypePluginBase.php, line 342
Class
- ExtraFieldTypePluginBase
- Define extra field type plugin base.
Namespace
Drupal\entity_extra_fieldCode
protected function getEntityFieldReferenceTypes($entity_type_id, $entity_bundle) {
$types = [];
$fields = $this->entityFieldManager
->getFieldDefinitions($entity_type_id, $entity_bundle);
foreach ($fields as $field_name => $field) {
if ($field
->getType() !== 'entity_reference') {
continue;
}
$definition = $field
->getFieldStorageDefinition();
$target_type = $definition
->getSetting('target_type');
if (!isset($target_type) || in_array($target_type, $types)) {
continue;
}
$type_definition = $this->entityTypeManager
->getDefinition($target_type);
if (!$type_definition instanceof ContentEntityTypeInterface) {
continue;
}
$types[$field_name] = $target_type;
}
return $types;
}