protected function MenuLinkFormatterTest::renderLink in Menu Link (Field) 8
Renders a menu link field.
Parameters
$entity: The entity to render the link for.
string|array $type: The ID of the field formatter.
string|array $settings: The field formatter settings.
Return value
string The rendered output.
1 call to MenuLinkFormatterTest::renderLink()
- MenuLinkFormatterTest::testMenuLinkFormatters in tests/
src/ Kernel/ MenuLinkFormatterTest.php - Tests the menu_link and menu_link_breadcrumb field formatters.
File
- tests/
src/ Kernel/ MenuLinkFormatterTest.php, line 149
Class
- MenuLinkFormatterTest
- Tests the menu link field formatters.
Namespace
Drupal\Tests\menu_link\KernelCode
protected function renderLink($entity, $type, $settings) : string {
$display = \Drupal::service('entity_display.repository')
->getViewDisplay('entity_test_mul', 'entity_test_mul', 'default')
->setComponent('field_menu_link', [
'type' => $type,
'settings' => $settings,
]);
$content = $display
->build($entity);
return $this
->render($content);
}