You are here

public function HandlerBase::getEntityType in Drupal 9

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

Determines the entity type used by this handler.

If this handler uses a relationship, the base class of the relationship is taken into account.

Return value

string The machine name of the entity type.

Overrides ViewsHandlerInterface::getEntityType

13 calls to HandlerBase::getEntityType()
BulkForm::getEntityTypeId in core/modules/views/src/Plugin/views/field/BulkForm.php
Returns the entity type identifier.
BulkForm::init in core/modules/views/src/Plugin/views/field/BulkForm.php
Initialize the plugin.
BulkForm::loadEntityFromBulkFormKey in core/modules/views/src/Plugin/views/field/BulkForm.php
Loads an entity based on a bulk form key.
Bundle::init in core/modules/views/src/Plugin/views/filter/Bundle.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().
EntityField::access in core/modules/views/src/Plugin/views/field/EntityField.php
Check whether given user has access to this handler.

... See full list

File

core/modules/views/src/Plugin/views/HandlerBase.php, line 702

Class

HandlerBase
Base class for Views handler plugins.

Namespace

Drupal\views\Plugin\views

Code

public function getEntityType() {

  // If the user has configured a relationship on the handler take that into
  // account.
  if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
    $relationship = $this->displayHandler
      ->getOption('relationships')[$this->options['relationship']];
    $table_data = $this
      ->getViewsData()
      ->get($relationship['table']);
    $views_data = $this
      ->getViewsData()
      ->get($table_data[$relationship['field']]['relationship']['base']);
  }
  else {
    $views_data = $this
      ->getViewsData()
      ->get($this->view->storage
      ->get('base_table'));
  }
  if (isset($views_data['table']['entity type'])) {
    return $views_data['table']['entity type'];
  }
  else {
    throw new \Exception("No entity type for field {$this->options['id']} on view {$this->view->storage->id()}");
  }
}