You are here

function admincss_page_attachments in Admin CSS 8.2

Implements hook_page_attachments().

File

./admincss.module, line 27
Hook implementations for the Admin CSS module.

Code

function admincss_page_attachments(array &$attachments) {
  $theme = \Drupal::theme()
    ->getActiveTheme()
    ->getName();
  $default_theme = \Drupal::config('system.theme')
    ->get('default');
  if ($default_theme === $theme) {
    if (file_exists('public://admin-style.css')) {
      $attachments['#attached']['library'][] = $theme . '/admincss.admincss';
    }

    // Add the admin css cache tags.
    $admincss_config = \Drupal::config('admincss.settings');
    $cacheable_metadata = CacheableMetadata::createFromObject($admincss_config);
    $cacheable_metadata
      ->applyTo($attachments);
  }
}