function SystemCompactLink::preRenderCompactLink
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Render/Element/SystemCompactLink.php \Drupal\Core\Render\Element\SystemCompactLink::preRenderCompactLink()
- 10 core/lib/Drupal/Core/Render/Element/SystemCompactLink.php \Drupal\Core\Render\Element\SystemCompactLink::preRenderCompactLink()
- 9 core/lib/Drupal/Core/Render/Element/SystemCompactLink.php \Drupal\Core\Render\Element\SystemCompactLink::preRenderCompactLink()
- 8.9.x core/lib/Drupal/Core/Render/Element/SystemCompactLink.php \Drupal\Core\Render\Element\SystemCompactLink::preRenderCompactLink()
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::l():
- #title: The link text to pass as argument to Drupal::l().
- One of the following:
- #route_name and (optionally) a #route_parameters array; The route name and route parameters which will be passed into the link generator.
- #href: The system path or URL to pass as argument to Drupal::l().
- #options: (optional) An array of options to pass to Drupal::l() or the link generator.
Return value
array The passed-in element containing the system compact link default values.
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ SystemCompactLink.php, line 57
Class
- SystemCompactLink
- Provides a link to show or hide help text on administration pages.
Namespace
Drupal\Core\Render\ElementCode
public static function preRenderCompactLink($element) {
$element['#title'] = t('Hide descriptions');
$element['#url'] = Url::fromUri('internal:#?');
$element['#options'] = [
'attributes' => [
'title' => t('Compress layout by hiding descriptions.'),
'data-admin-compact-toggle' => TRUE,
],
];
$element['#attached']['library'][] = 'system/drupal.system.admin_compact';
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.