function SelectionPluginManager::getPluginId

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

Overrides SelectionPluginManagerInterface::getPluginId

1 call to SelectionPluginManager::getPluginId()
SelectionPluginManager::getInstance in core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php

File

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

Class

SelectionPluginManager
Plugin type manager for Entity Reference Selection plugins.

Namespace

Drupal\Core\Entity\EntityReferenceSelection

Code

public function getPluginId($target_type, $base_plugin_id) {
    // Get all available selection plugins for this entity type.
    $selection_handler_groups = $this->getSelectionGroups($target_type);
    // Sort the selection plugins by weight and select the best match.
    uasort($selection_handler_groups[$base_plugin_id], [
        'Drupal\\Component\\Utility\\SortArray',
        'sortByWeightElement',
    ]);
    end($selection_handler_groups[$base_plugin_id]);
    $plugin_id = key($selection_handler_groups[$base_plugin_id]);
    return $plugin_id;
}

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