diff --git a/core/lib/Drupal/Core/Render/Element/MoreLink.php b/core/lib/Drupal/Core/Render/Element/MoreLink.php index 4f7e90c..6551abb 100644 --- a/core/lib/Drupal/Core/Render/Element/MoreLink.php +++ b/core/lib/Drupal/Core/Render/Element/MoreLink.php @@ -24,7 +24,7 @@ public function getInfo() { '#title' => $this->t('More'), '#theme_wrappers' => array( 'container' => array( - '#attributes' => array('class' => 'more-link'), + '#attributes' => array('class' => array('more-link')), ), ), ) + $info; diff --git a/core/modules/system/css/system.admin.css b/core/modules/system/css/system.admin.css index 853ded2..2c1269b 100644 --- a/core/modules/system/css/system.admin.css +++ b/core/modules/system/css/system.admin.css @@ -28,7 +28,7 @@ div.admin .expert-link { } /** - * Markup generated by theme_system_compact_link(). + * System compact link: to toggle the display of description text. */ .compact-link { margin: 0 0 0.5em 0; diff --git a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php index 6d83838..bffb4e6 100644 --- a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php +++ b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php @@ -184,4 +184,50 @@ function testMoreLink() { } } + /** + * Tests system #type 'system_compact_link'. + */ + function testSystemCompactLink() { + $elements = array( + array( + 'name' => "#type 'system_compact_link' when admin compact mode is off", + 'value' => array( + '#type' => 'system_compact_link', + ), + 'expected' => '//div[@class="compact-link"]/a[contains(@href, "admin/compact/on") and text()="Hide descriptions"]', + ), + array( + 'name' => "#type 'system_compact_link' when adding extra attributes", + 'value' => array( + '#type' => 'system_compact_link', + '#attributes' => array( + 'class' => array('kittens-rule'), + ), + ), + 'expected' => '//div[@class="compact-link"]/a[contains(@href, "admin/compact/on") and @class="kittens-rule" and text()="Hide descriptions"]', + ), + ); + + foreach ($elements as $element) { + $xml = new \SimpleXMLElement(drupal_render($element['value'])); + $result = $xml->xpath($element['expected']); + $this->assertTrue($result, '"' . $element['name'] . '" is rendered correctly by drupal_render().'); + } + + // Set admin compact mode on for additional tests. + \Drupal::request()->cookies->set('Drupal_visitor_admin_compact_mode', TRUE); + + $element = array( + 'name' => "#type 'system_compact_link' when admin compact mode is on", + 'value' => array( + '#type' => 'system_compact_link', + ), + 'expected' => '//div[@class="compact-link"]/a[contains(@href, "admin/compact/off") and text()="Show descriptions"]', + ); + + $xml = new \SimpleXMLElement(drupal_render($element['value'])); + $result = $xml->xpath($element['expected']); + $this->assertTrue($result, '"' . $element['name'] . '" is rendered correctly by drupal_render().'); + } + } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 57edc26..0fc5922 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -84,7 +84,7 @@ function template_preprocess_admin_block_content(&$variables) { */ function template_preprocess_admin_page(&$variables) { $variables['system_compact_link'] = array( - '#theme' => 'system_compact_link', + '#type' => 'system_compact_link', ); $variables['containers'] = array(); $stripe = 0; @@ -113,7 +113,7 @@ function template_preprocess_admin_page(&$variables) { */ function template_preprocess_system_admin_index(&$variables) { $variables['system_compact_link'] = array( - '#theme' => 'system_compact_link', + '#type' => 'system_compact_link', ); $variables['containers'] = array(); $stripe = 0; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 3f19f14..a5628bf 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -212,9 +212,6 @@ function system_theme() { 'file' => 'system.admin.inc', 'template' => 'system-admin-index', ), - 'system_compact_link' => array( - 'variables' => array(), - ), )); } @@ -1168,24 +1165,6 @@ function system_time_zones($blank = NULL) { } /** - * Returns HTML for a link to show or hide inline help descriptions. - * - * @ingroup themeable - */ -function theme_system_compact_link() { - $output = ''; - - return $output; -} - -/** * Attempts to get a file using Guzzle HTTP client and to store it locally. * * @param string $url diff --git a/core/modules/user/src/Form/UserPermissionsForm.php b/core/modules/user/src/Form/UserPermissionsForm.php index 3f89bb6..1a6643a 100644 --- a/core/modules/user/src/Form/UserPermissionsForm.php +++ b/core/modules/user/src/Form/UserPermissionsForm.php @@ -97,7 +97,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $hide_descriptions = system_admin_compact_mode(); $form['system_compact_link'] = array( - '#theme' => 'system_compact_link', + '#type' => 'system_compact_link', ); $form['permissions'] = array(