SystemCompactLink.php in Zircon Profile 8
File
core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
View source
<?php
namespace Drupal\Core\Render\Element;
use Drupal\Core\Url as BaseUrl;
use Drupal\Component\Utility\NestedArray;
class SystemCompactLink extends Link {
public function getInfo() {
$class = get_class($this);
return array(
'#pre_render' => array(
array(
$class,
'preRenderCompactLink',
),
array(
$class,
'preRenderLink',
),
),
'#theme_wrappers' => array(
'container' => array(
'#attributes' => array(
'class' => array(
'compact-link',
),
),
),
),
);
}
public static function preRenderCompactLink($element) {
$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;
}
}
Classes
Name |
Description |
SystemCompactLink |
Provides a link render element to show or hide inline help descriptions. |