\Drupflare\Anachron\Drupal\Menu LegacyLocalTasksAlter

Calls `hook_menu_local_tasks_alter()` with the arguments each implementation was written for.

Drupal 7 passed (&$data, $router_item, $root_path) with tabs and actions as lists of menu_local_task render arrays. Drupal 11 passes (&$data, $route_name, $cacheability) with tabs keyed by plugin id. An implementation whose second parameter is route_name or a string is a Drupal 11 one and is called as core calls it. Any other is a Drupal 7 one: it gets the tabs rebuilt in the Drupal 7 shape and its edits are folded back. Tabs it removes are removed, tabs it adds are added with an access check, a changed title or weight is kept. Local actions it adds are not applied, because Drupal 11 builds actions in another manager, and each one is recorded as refused. LegacyAlterModuleHandler routes the alter here.

Summary

Methods
Properties
Constants
__construct
run
isLegacy
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
callLegacy
toLegacyData
toLegacyTab
foldBack
addTab
handler
rootPath
MARK

Constant

MARK

MARK = '#anachron_key'

Properties

$handler

$handler : \Drupal\Core\Extension\ModuleHandlerInterface

Type

ModuleHandlerInterface

$rootPath

$rootPath

Methods

__construct()

__construct(\Drupal\Core\Extension\ModuleHandlerInterface  $handler, callable  $rootPath) : mixed

Parameters

\Drupal\Core\Extension\ModuleHandlerInterface $handler

The handler that finds the implementations.

callable $rootPath

Maps a route name to the Drupal 7 router path, such as admin/apps/%.

Returns

mixed —

run()

run(array  $data, string  $route_name, \Drupal\Core\Cache\CacheableMetadata  $cacheability) : void

Runs the `menu_local_tasks` alter, giving each implementation its own arguments.

Parameters

array $data

The Drupal 11 data, edited in place.

string $route_name

The route the tasks are for.

\Drupal\Core\Cache\CacheableMetadata $cacheability

The cacheability the implementations add to.

Returns

void —

isLegacy()

isLegacy(callable  $hook) : bool

Tells whether an implementation takes the Drupal 7 arguments.

Parameters

callable $hook

The implementation.

Returns

bool —

callLegacy()

callLegacy(callable  $hook, string  $module, array  $data, string  $route_name, \Drupal\Core\Cache\CacheableMetadata  $cacheability) : void

Calls one Drupal 7 implementation and folds its edits into the Drupal 11 data.

Parameters

callable $hook

The implementation.

string $module

The module that owns it.

array $data

The Drupal 11 data, edited in place.

string $route_name

The route the tasks are for.

\Drupal\Core\Cache\CacheableMetadata $cacheability

The cacheability to add the access results to.

Returns

void —

toLegacyData()

toLegacyData(array  $data, string  $root_path) : array<string,mixed>

Builds the Drupal 7 data array from the Drupal 11 one.

Parameters

array $data

The Drupal 11 data.

string $root_path

The Drupal 7 router path.

Returns

array —

Tabs by level and an empty action list, as hook_menu_local_tasks_alter() received them.

toLegacyTab()

toLegacyTab(string  $key, array  $build) : array<string,mixed>

Builds one Drupal 7 tab from a Drupal 11 local task render array.

Parameters

string $key

The plugin id.

array $build

The render array.

Returns

array —

The menu_local_task render array.

foldBack()

foldBack(array  $data, array>  $tabs, string  $module, \Drupal\Core\Cache\CacheableMetadata  $cacheability) : void

Applies what a Drupal 7 implementation did to the tabs.

Parameters

array $data

The Drupal 11 data, edited in place.

array> $tabs

The Drupal 7 tabs after the call.

string $module

The module that made the edits.

\Drupal\Core\Cache\CacheableMetadata $cacheability

The cacheability to add access results to.

Returns

void —

addTab()

addTab(array  $data, int|string  $level, string  $key, array  $tab, string  $module, \Drupal\Core\Cache\CacheableMetadata  $cacheability) : void

Adds a tab that a Drupal 7 implementation created, denied unless access can be decided.

Parameters

array $data

The Drupal 11 data, edited in place.

int|string $level

The tab level.

string $key

The key to store the tab under.

array $tab

The Drupal 7 tab.

string $module

The module that added it.

\Drupal\Core\Cache\CacheableMetadata $cacheability

The cacheability to add the access result to.

Returns

void —