function ConfigActionManager::getShorthandActionIdsForEntityType

Same name in other branches
  1. 10 core/lib/Drupal/Core/Config/Action/ConfigActionManager.php \Drupal\Core\Config\Action\ConfigActionManager::getShorthandActionIdsForEntityType()

Gets a map of shorthand action IDs to plugin IDs for an entity type.

Parameters

string $entityType: The entity type ID to get the map for.

Return value

string[] An array of plugin IDs keyed by shorthand action ID for the provided entity type.

1 call to ConfigActionManager::getShorthandActionIdsForEntityType()
ConfigActionManager::applyAction in core/lib/Drupal/Core/Config/Action/ConfigActionManager.php
Applies a config action.

File

core/lib/Drupal/Core/Config/Action/ConfigActionManager.php, line 235

Class

ConfigActionManager

Namespace

Drupal\Core\Config\Action

Code

protected function getShorthandActionIdsForEntityType(string $entityType) : array {
    $map = [];
    foreach ($this->getDefinitions() as $plugin_id => $definition) {
        if (in_array($entityType, $definition['entity_types'], TRUE) || in_array('*', $definition['entity_types'], TRUE)) {
            $regex = '/' . PluginBase::DERIVATIVE_SEPARATOR . '([^' . PluginBase::DERIVATIVE_SEPARATOR . ']*)$/';
            $action_id = preg_match($regex, $plugin_id, $matches) ? $matches[1] : $plugin_id;
            if (isset($map[$action_id])) {
                throw new DuplicateConfigActionIdException(sprintf('The plugins \'%s\' and \'%s\' both resolve to the same shorthand action ID for the \'%s\' entity type', $plugin_id, $map[$action_id], $entityType));
            }
            $map[$action_id] = $plugin_id;
        }
    }
    return $map;
}

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