You are here

protected function FieldFormatterConditionBase::getEntityType in Field Formatter Condition 8

Check for entity_type in build.

Parameters

array $build: The current build array.

1 call to FieldFormatterConditionBase::getEntityType()
FieldFormatterConditionBase::getEntity in src/Plugin/FieldFormatterConditionBase.php
Check for entity in build.

File

src/Plugin/FieldFormatterConditionBase.php, line 74

Class

FieldFormatterConditionBase
Base class for Field formatter condition plugins.

Namespace

Drupal\fico\Plugin

Code

protected function getEntityType(array $build) {
  if (isset($build['#entity_type'])) {
    return $build['#entity_type'];
  }
  $types = \Drupal::entityManager()
    ->getDefinitions();
  foreach ($types as $id => $type) {
    if (!is_a($type, 'Drupal\\Core\\Entity\\ContentEntityType')) {
      continue;
    }
    if (isset($build['#' . $id])) {
      return $id;
    }
  }
  return NULL;
}