You are here

public function TokenEntityMapper::getEntityTypeMappings in Token 8

Return an array of entity type to token type mappings.

Return value

array An array of mappings with entity type mapping to token type.

Overrides TokenEntityMapperInterface::getEntityTypeMappings

2 calls to TokenEntityMapper::getEntityTypeMappings()
TokenEntityMapper::getEntityTypeForTokenType in src/TokenEntityMapper.php
Return the entity type of a particular token type.
TokenEntityMapper::getTokenTypeForEntityType in src/TokenEntityMapper.php
Return the token type of a particular entity type.

File

src/TokenEntityMapper.php, line 40

Class

TokenEntityMapper
Service to provide mappings between entity and token types.

Namespace

Drupal\token

Code

public function getEntityTypeMappings() {
  if (empty($this->entityMappings)) {
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type => $info) {
      $this->entityMappings[$entity_type] = $info
        ->get('token_type') ?: $entity_type;
    }

    // Allow modules to alter the mapping array.
    $this->moduleHandler
      ->alter('token_entity_mapping', $this->entityMappings);
  }
  return $this->entityMappings;
}