public static SystemCompactLink::preRenderCompactLink($element)
Pre-render callback: Renders a link into #markup.
Doing so during pre_render gives modules a chance to alter the link parts.
array $element: A structured array whose keys form the arguments to Drupal::l():
array The passed-in element containing the system compact link default values.
public static function preRenderCompactLink($element) { // By default, link options to pass to l() are normally set in #options. $element += array('#options' => array()); if (system_admin_compact_mode()) { $element['#title'] = t('Show descriptions'); $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'off')); $element['#options'] = array( 'attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => \Drupal::destination()->getAsArray() ); } else { $element['#title'] = t('Hide descriptions'); $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'on')); $element['#options'] = array( 'attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => \Drupal::destination()->getAsArray(), ); } $options = NestedArray::mergeDeep($element['#url']->getOptions(), $element['#options']); $element['#markup'] = \Drupal::l($element['#title'], $element['#url']->setOptions($options)); return $element; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!SystemCompactLink.php/function/SystemCompactLink::preRenderCompactLink/8.1.x