function HandlerBase::getEntityType

Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::getEntityType()
  2. 10 core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::getEntityType()
  3. 11.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::getEntityType()

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 713

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()}");
    }
}

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