You are here

protected function ExtraFieldTypePluginBase::getEntityTokenTypes in Entity Extra Field 2.0.x

Same name and namespace in other branches
  1. 8 src/ExtraFieldTypePluginBase.php \Drupal\entity_extra_field\ExtraFieldTypePluginBase::getEntityTokenTypes()

Get entity token types.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

string $entity_bundle: The entity bundle name.

Return value

array An array of the entity token types.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

2 calls to ExtraFieldTypePluginBase::getEntityTokenTypes()
ExtraFieldTokenPlugin::buildConfigurationForm in src/Plugin/ExtraFieldType/ExtraFieldTokenPlugin.php
Form constructor.
ExtraFieldViewsPlugin::buildConfigurationForm in src/Plugin/ExtraFieldType/ExtraFieldViewsPlugin.php
Form constructor.

File

src/ExtraFieldTypePluginBase.php, line 291

Class

ExtraFieldTypePluginBase
Define extra field type plugin base.

Namespace

Drupal\entity_extra_field

Code

protected function getEntityTokenTypes(EntityTypeInterface $entity_type, string $entity_bundle) : array {
  $types = array_values($this
    ->getEntityFieldReferenceTypes($entity_type
    ->id(), $entity_bundle));
  $token_type = $entity_type
    ->get('token_type') ?? $entity_type
    ->id();
  if (!in_array($token_type, $types, TRUE)) {
    $types[] = $token_type;
  }
  return $types;
}