You are here

public function ViewExecutable::getBaseEntityType in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::getBaseEntityType()

Returns the entity type of the base table, if available.

Return value

\Drupal\Core\Entity\EntityType|false The entity type of the base table, or FALSE if none exists.

File

core/modules/views/src/ViewExecutable.php, line 987

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public function getBaseEntityType() {
  if (!isset($this->baseEntityType)) {
    $view_base_table = $this->storage
      ->get('base_table');
    $views_data = $this->viewsData
      ->get($view_base_table);
    if (!empty($views_data['table']['entity type'])) {
      $entity_type_id = $views_data['table']['entity type'];
      $this->baseEntityType = \Drupal::entityTypeManager()
        ->getDefinition($entity_type_id);
    }
    else {
      $this->baseEntityType = FALSE;
    }
  }
  return $this->baseEntityType;
}