You are here

function TokenEntityMapper::getEntityTypeForTokenType in Token 8

Return the entity type of a particular token type.

Parameters

string $token_type: The token type for which the mapping is returned.

bool $fallback: (optional) Defaults to FALSE. If true, the same $value is returned in case the mapping was not found.

Return value

string The entity type of the token type specified.

Overrides TokenEntityMapperInterface::getEntityTypeForTokenType

See also

token_entity_info_alter()

http://drupal.org/node/737726

File

src/TokenEntityMapper.php, line 55

Class

TokenEntityMapper
Service to provide mappings between entity and token types.

Namespace

Drupal\token

Code

function getEntityTypeForTokenType($token_type, $fallback = FALSE) {
  if (empty($this->entityMappings)) {
    $this
      ->getEntityTypeMappings();
  }
  $return = array_search($token_type, $this->entityMappings);
  return $return !== FALSE ? $return : ($fallback ? $token_type : FALSE);
}