function EntityReference::getSelectionHandler

Gets the entity reference selection handler.

Parameters

string|null $sub_handler: The sub handler to get an instance of or NULL for the current selection.

Return value

\Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface The selection handler plugin instance.

3 calls to EntityReference::getSelectionHandler()
EntityReference::buildExtraOptionsForm in core/modules/views/src/Plugin/views/filter/EntityReference.php
Provide a form for setting options.
EntityReference::calculateDependencies in core/modules/views/src/Plugin/views/filter/EntityReference.php
Calculates dependencies for the configured plugin.
EntityReference::init in core/modules/views/src/Plugin/views/filter/EntityReference.php
Overrides \Drupal\views\Plugin\views\HandlerBase::init().

File

core/modules/views/src/Plugin/views/filter/EntityReference.php, line 131

Class

EntityReference
Filters a view by entity references.

Namespace

Drupal\views\Plugin\views\filter

Code

protected function getSelectionHandler(?string $sub_handler = NULL) : SelectionInterface {
    // Default values for the handler.
    $handler_settings = $this->options['sub_handler_settings'] ?? [];
    $handler_settings['handler'] = $sub_handler;
    $handler_settings['target_type'] = $this->getReferencedEntityType()
        ->id();
    
    /** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface */
    return $this->selectionPluginManager
        ->getInstance($handler_settings);
}

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