You are here

public static function LinkElement::preRenderLink in Field Group Link 8

Same name and namespace in other branches
  1. 8.3 src/Element/LinkElement.php \Drupal\field_group_link\Element\LinkElement::preRenderLink()

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/LinkElement.php, line 20

Class

LinkElement
Provides a link render element for Field Groups.

Namespace

Drupal\field_group_link\Element

Code

public static function preRenderLink($element) {

  // Remove child elements that have been added to $element['#title'].
  // Otherwise they will appear twice on the page.
  foreach (Element::children($element['#title']) as $child) {
    if (isset($element[$child])) {
      unset($element[$child]);
    }
  }
  return parent::preRenderLink($element);
}