public function TwigExtension::contextualLinks in Twig Tweak 8.2
Builds contextual links.
Parameters
string $id: A serialized representation of a #contextual_links property value array.
Return value
array A renderable array representing contextual links.
See also
https://www.drupal.org/node/2133283
File
- src/
TwigExtension.php, line 988
Class
- TwigExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public function contextualLinks($id) {
$build['#cache']['contexts'] = [
'user.permissions',
];
if (\Drupal::currentUser()
->hasPermission('access contextual links')) {
$build['#type'] = 'contextual_links_placeholder';
$build['#id'] = $id;
}
return $build;
}