function SelectionPluginManager::getInstance

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getInstance()
  2. 10 core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getInstance()
  3. 11.x core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getInstance()

Overrides PluginManagerBase::getInstance

1 call to SelectionPluginManager::getInstance()
SelectionPluginManager::getSelectionHandler in core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php
Gets the selection handler for a given entity_reference field.

File

core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php, line 34

Class

SelectionPluginManager
Plugin type manager for Entity Reference Selection plugins.

Namespace

Drupal\Core\Entity\EntityReferenceSelection

Code

public function getInstance(array $options) {
    if (!isset($options['target_type'])) {
        throw new \InvalidArgumentException("Missing required 'target_type' property for a EntityReferenceSelection plugin.");
    }
    // Initialize default options.
    $options += [
        'handler' => $this->getPluginId($options['target_type'], 'default'),
    ];
    // A specific selection plugin ID was already specified.
    if (strpos($options['handler'], ':') !== FALSE) {
        $plugin_id = $options['handler'];
    }
    else {
        $plugin_id = $this->getPluginId($options['target_type'], $options['handler']);
    }
    unset($options['handler']);
    return $this->createInstance($plugin_id, $options);
}

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