function TestController::duplicateContextualLinks
Renders two regions with the same contextual links.
1 string reference to 'TestController::duplicateContextualLinks'
- contextual_test.routing.yml in core/
modules/ contextual/ tests/ modules/ contextual_test/ contextual_test.routing.yml - core/modules/contextual/tests/modules/contextual_test/contextual_test.routing.yml
File
-
core/
modules/ contextual/ tests/ modules/ contextual_test/ src/ Controller/ TestController.php, line 38
Class
- TestController
- Test controller to provide a callback for the contextual link.
Namespace
Drupal\contextual_test\ControllerCode
public function duplicateContextualLinks() : array {
$contextual_id = $this->serializer
->linksToId([
'contextual_test' => [
'route_parameters' => [],
],
]);
$build = [];
foreach ([
'first',
'second',
] as $id) {
$build[$id] = [
'#type' => 'inline_template',
'#template' => '<div id="region-{{ id }}" class="contextual-region">{{ placeholder }}Region {{ id }}</div>',
'#context' => [
'id' => $id,
'placeholder' => [
'#type' => 'contextual_links_placeholder',
'#id' => $contextual_id,
],
],
];
}
return $build;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.