You are here

LinkElement.php in Field Group Link 8.3

Same filename and directory in other branches
  1. 8 src/Element/LinkElement.php

File

src/Element/LinkElement.php
View source
<?php

namespace Drupal\field_group_link\Element;

use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\Link;

/**
 * Provides a link render element for Field Groups.
 *
 * @see \Drupal\Core\Render\Element\Link
 *
 * @RenderElement("field_group_link")
 */
class LinkElement extends Link {

  /**
   * {@inheritdoc}
   */
  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);
  }

}

Classes

Namesort descending Description
LinkElement Provides a link render element for Field Groups.