\Drupflare\Anachron\Drupal\Extension LegacyAlterModuleHandler

The module handler, with the alters whose Drupal 7 and Drupal 11 arguments differ.

Only menu_local_tasks and system_info are routed away and element_info gets stubs for the Drupal 7 types Drupal 11 lacks; every other alter is core's. Entity load and access hooks of types Drupal 7 had no such hook for skip procedural functions that only share the name, and the results of an access hook are read as Drupal 11 access results.

Summary

Methods
Properties
Constants
alter
invokeAllWith
invokeAll
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
noOpinion
isLoadHookWithoutDrupalSeven
guardAccessListener
rootPath
No private properties found
D7_LOAD_HOOKS

Constant

D7_LOAD_HOOKS

D7_LOAD_HOOKS = ['entity', 'node', 'user', 'comment', 'taxonomy_term', 'taxonomy_vocabulary', 'file']

The entity types Drupal 7 called a `hook_TYPE_load()` for.

Methods

alter()

alter(string|string[]  $type, mixed  $data, mixed  $context1 = null, mixed  $context2 = null) : mixed

Alters data, giving legacy local task implementations the Drupal 7 arguments.

Parameters

string|string[] $type

The alter type.

mixed $data

The data to alter.

mixed $context1

The first context argument.

mixed $context2

The second context argument.

Returns

mixed —

invokeAllWith()

invokeAllWith(string  $hook, callable  $callback) : void

Invokes a hook, skipping procedural functions that only share its name.

Drupal 11 calls MODULE_TYPE_load($entities) for every entity type, config ones included. A Drupal 7 module can own a function by that name for another reason (Features' features_filter_format_load($name) is a loader helper), and calling it with an array of entities is a fatal. Drupal 7 had a load hook for the types in D7_LOAD_HOOKS only, so a procedural implementation of any other type's hook is skipped and recorded.

Parameters

string $hook

The hook name.

callable $callback

Receives each implementation and its module.

Returns

void —

invokeAll()

invokeAll(string  $hook, array  $args = []) : mixed

Invokes a hook and reads the results of an access hook as access results.

Drupal 7's hook_node_access() answered allow, deny or ignore strings, and a Drupal 11 caller combines the results with orIf(), which fatals on anything else. The strings map to allowed, forbidden and neutral. Any other value is no opinion, and is recorded.

Parameters

string $hook

The hook name.

array $args

The arguments.

Returns

mixed —

noOpinion()

noOpinion(string  $hook, mixed  $result) : \Drupal\Core\Access\AccessResultInterface

Parameters

string $hook
mixed $result

Returns

\Drupal\Core\Access\AccessResultInterface —

isLoadHookWithoutDrupalSeven()

isLoadHookWithoutDrupalSeven(string  $hook) : bool

Parameters

string $hook

Returns

bool —

guardAccessListener()

guardAccessListener(string  $hook, mixed  $listener) : mixed

Wraps a procedural access implementation that needs more arguments than the hook passes.

Drupal 11 calls MODULE_entity_access($entity, $operation, $account) for every module. A Drupal 7 module can own a helper by that name with another signature (Search API's takes none and answers a boolean), which is called and read as no opinion. One that requires more arguments than the hook has would be an ArgumentCountError, so it is skipped and recorded.

Parameters

string $hook
mixed $listener

Returns

mixed —

rootPath()

rootPath(string  $route_name) : string

Gives the Drupal 7 router path of a route, such as `admin/apps/%`.

Parameters

string $route_name

The route name.

Returns

string —