You are here

public function StaticMenuLinkOverrides::loadMultipleOverrides in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php \Drupal\Core\Menu\StaticMenuLinkOverrides::loadMultipleOverrides()
  2. 10 core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php \Drupal\Core\Menu\StaticMenuLinkOverrides::loadMultipleOverrides()

Loads overrides to multiple definitions of a static (YAML-defined) link.

Parameters

array $ids: Array of menu link plugin IDs.

Return value

array One or override keys by plugin ID.

Overrides StaticMenuLinkOverridesInterface::loadMultipleOverrides

See also

\Drupal\Core\Menu\StaticMenuLinkOverridesInterface

File

core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php, line 108

Class

StaticMenuLinkOverrides
Defines an implementation of the menu link override using a config file.

Namespace

Drupal\Core\Menu

Code

public function loadMultipleOverrides(array $ids) {
  $result = [];
  if ($ids) {
    $all_overrides = $this
      ->getConfig()
      ->get('definitions') ?: [];
    foreach ($ids as $id) {
      $encoded_id = static::encodeId($id);
      if (isset($all_overrides[$encoded_id])) {
        $result[$id] = $all_overrides[$encoded_id];
      }
    }
  }
  return $result;
}