class StaticMenuLinkOverrides implements StaticMenuLinkOverridesInterface (View source)

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

Properties

protected string $configName

The config name used to store the overrides.

protected Config $config

The menu link overrides config object.

protected ConfigFactoryInterface $configFactory

The config factory object.

Methods

__construct(ConfigFactoryInterface $config_factory)

Constructs a StaticMenuLinkOverrides object.

getConfig()

Gets the configuration object when needed.

reload()

Reloads the overrides from config.

array|null
loadOverride(string $id)

Loads any overrides to the definition of a static (YAML-defined) link.

deleteMultipleOverrides(array $ids)

Deletes multiple overrides to definitions of static (YAML-defined) links.

deleteOverride(string $id)

Deletes any overrides to the definition of a static (YAML-defined) link.

array
loadMultipleOverrides(array $ids)

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

array
saveOverride(string $id, array $definition)

Saves the override.

string[]
getCacheTags()

The unique cache tag associated with this menu link override.

static string
encodeId(string $id)

Encodes the ID by replacing dots with double underscores.

Details

__construct(ConfigFactoryInterface $config_factory)

Constructs a StaticMenuLinkOverrides object.

Parameters

ConfigFactoryInterface $config_factory

A configuration factory instance.

protected getConfig()

Gets the configuration object when needed.

Since this service is injected into all static menu link objects, but only used when updating one, avoid actually loading the config when it's not needed.

reload()

Reloads the overrides from config.

Forces all overrides to be reloaded from config storage to compare the override value with the value submitted during test form submission.

array|null loadOverride(string $id)

Loads any overrides to the definition of a static (YAML-defined) link.

Parameters

string $id

A menu link plugin ID.

Return Value

array|null

An override with following supported keys:

  • parent
  • weight
  • menu_name
  • expanded
  • enabled or NULL if there is no override for the given ID.

deleteMultipleOverrides(array $ids)

Deletes multiple overrides to definitions of static (YAML-defined) links.

Parameters

array $ids

Array of menu link plugin IDs.

deleteOverride(string $id)

Deletes any overrides to the definition of a static (YAML-defined) link.

Parameters

string $id

A menu link plugin ID.

array loadMultipleOverrides(array $ids)

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.

array saveOverride(string $id, array $definition)

Saves the override.

Parameters

string $id

A menu link plugin ID.

array $definition

The definition values to override. Supported keys:

  • menu_name
  • parent
  • weight
  • expanded
  • enabled

Return Value

array

A list of properties which got saved.

string[] getCacheTags()

The unique cache tag associated with this menu link override.

Return Value

string[]

An array of cache tags.

static protected string encodeId(string $id)

Encodes the ID by replacing dots with double underscores.

This is done because config schema uses dots for its internal type hierarchy. Double underscores are converted to triple underscores to avoid accidental conflicts.

Parameters

string $id

The menu plugin ID.

Return Value

string

The menu plugin ID with double underscore instead of dots.