function ViewExecutable::getBaseEntityType

Same name and namespace in other branches
  1. 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::getBaseEntityType()
  2. 10 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::getBaseEntityType()
  3. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.