You are here

protected function EntityEmbedDisplayBase::isValidEntityType in Entity Embed 8

Validates that this display plugin applies to the current entity type.

This checks the plugin annotation's 'entity_types' value, which should be an array of entity types that this plugin can process, or FALSE if the plugin applies to all entity types.

Return value

bool TRUE if the plugin can display the current entity type, or FALSE otherwise.

File

src/EntityEmbedDisplay/EntityEmbedDisplayBase.php, line 113

Class

EntityEmbedDisplayBase
Defines a base Entity Embed Display implementation.

Namespace

Drupal\entity_embed\EntityEmbedDisplay

Code

protected function isValidEntityType() {

  // First, determine whether or not the entity type id is valid. Return FALSE
  // if the specified id is not valid.
  $entity_type = $this
    ->getEntityTypeFromContext();
  if (!$this->entityTypeManager
    ->getDefinition($entity_type)) {
    return FALSE;
  }
  $definition = $this
    ->getPluginDefinition();
  if ($definition['entity_types'] === FALSE) {
    return TRUE;
  }
  else {
    return in_array($entity_type, $definition['entity_types']);
  }
}