public function ForwardLinkGenerator::generate in Forward 4.0.x
Same name and namespace in other branches
- 4.x src/Services/ForwardLinkGenerator.php \Drupal\forward\Services\ForwardLinkGenerator::generate()
Generate a Forward link for a given entity.
See ForwardLinkFormatter.php for example usage.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: Entity for which the link is being generated.
array $settings: Array with these keys: title - the link title, with tokens allowed style - 0, 1, or 2 (text only, icon only, text and icon) icon - optional path to custom icon, or a blank string nofollow - true if a nofollow tag should be included.
Return value
array A render array containing the generated link.
Overrides ForwardLinkGeneratorInterface::generate
File
- src/
Services/ ForwardLinkGenerator.php, line 68
Class
- ForwardLinkGenerator
- Defines a class for generating a Forward link on an entity.
Namespace
Drupal\forward\ServicesCode
public function generate(EntityInterface $entity, array $settings) {
$link = $this
->generateLink($entity, $settings);
$render_array = [
'#theme' => 'forward_link_formatter',
'#link' => $link,
'#attached' => [
'library' => [
'forward/forward',
],
],
];
return $render_array;
}