By claudiu.cristea on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.4.x
Introduced in version:
11.4.0
Issue links:
Description:
The _contextual_links_to_id() & _contextual_id_to_links() functions are deprecated and their functionality has been moved to a new Drupal\contextual\ContextualLinksSerializer service.
Before
$variables['title_suffix']['contextual_links'] = [
'#type' => 'contextual_links_placeholder',
'#id' => _contextual_links_to_id($element['#contextual_links']),
];
...
$element = [
'#type' => 'contextual_links',
'#contextual_links' => _contextual_id_to_links($id),
];
After
use use Drupal\contextual\ContextualLinksSerializer;
...
// Inject when possible.
$service = \Drupal::service(ContextualLinksSerializer::class);
$variables['title_suffix']['contextual_links'] = [
'#type' => 'contextual_links_placeholder',
'#id' => $service->linksToId($element['#contextual_links']),
];
...
$element = [
'#type' => 'contextual_links',
'#contextual_links' => $service->idToLinks($id),
];
Impacts:
Module developers
Site templates, recipes and distribution developers