You are here

public static function PrintLink::preRenderLink in Entity Print 8.2

Pre-render callback: Renders a link into #markup.

Doing so during pre_render gives modules a chance to alter the link parts.

Parameters

array $element: A structured array whose keys form the arguments to \Drupal\Core\Utility\LinkGeneratorInterface::generate():

  • #title: The link text.
  • #url: The URL info either pointing to a route or a non routed path.
  • #options: (optional) An array of options to pass to the link generator.

Return value

array The passed-in element containing a rendered link in '#markup'.

Overrides Link::preRenderLink

File

src/Element/PrintLink.php, line 33

Class

PrintLink
The print link.

Namespace

Drupal\entity_print\Element

Code

public static function preRenderLink($element) {
  if (isset($element['#export_type'])) {
    $element['#attributes']['class'][] = 'print__link--' . $element['#export_type'];
    $element['#theme_wrappers']['container']['#attributes']['class'][] = 'print__wrapper--' . Html::cleanCssIdentifier($element['#export_type']);
  }
  return parent::preRenderLink($element);
}