You are here

class ThemeInfo in AT Tools 8.3

Same name and namespace in other branches
  1. 8 at_theme_generator/src/Theme/ThemeInfo.php \Drupal\at_theme_generator\Theme\ThemeInfo
  2. 8.2 at_theme_generator/src/Theme/ThemeInfo.php \Drupal\at_theme_generator\Theme\ThemeInfo

ThemeSettingsInfo declares methods used to return theme info for use in theme-settings.php. Note the constructor calls system_rebuild_theme_data() which is not statically cached therefor only used in the backend, however it always returns fresh data.

Hierarchy

  • class \Drupal\at_theme_generator\Theme\ThemeInfo

Expanded class hierarchy of ThemeInfo

1 file declares its use of ThemeInfo
GeneratorForm.php in at_theme_generator/src/Form/GeneratorForm.php

File

at_theme_generator/src/Theme/ThemeInfo.php, line 16
Contains \Drupal\at_theme_generator\Theme\ThemeInfo.

Namespace

Drupal\at_theme_generator\Theme
View source
class ThemeInfo {

  /**
   * Constructs a theme info object.
   */
  public function __construct() {
    $this->data = \Drupal::service('theme_handler')
      ->rebuildThemeData();
  }

  /**
   * Return list of base theme options.
   * Looks for all themes with a base theme value of 'at_core' and returns
   * the list. This means you cannot sub-theme a "skin" type sub-theme.
   *
   * @param $subtheme_type
   * @return array
   */
  public function themeOptions($subtheme_type) {
    $base_themes = [];
    foreach ($this->data as $machine_name => $theme) {
      foreach ($theme as $theme_key => $theme_values) {
        if ($theme_key === 'info') {
          if (isset($theme_values['subtheme type']) && $theme_values['subtheme type'] === $subtheme_type) {
            $base_themes[$machine_name] = $machine_name;
          }
        }
      }
    }

    // These are just generator "templates, not to be used directly. BC.
    unset($base_themes['at_standard']);
    unset($base_themes['at_minimal']);
    unset($base_themes['at_skin']);
    unset($base_themes['at_starterkit']);
    unset($base_themes['at_generator']);
    unset($base_themes['THEMENAME']);
    unset($base_themes['STARTERKIT']);
    unset($base_themes['SKIN']);
    return $base_themes;
  }

  /**
   * Check if a theme name already exists.
   * Looks in the list of themes to see if a theme name already exists, if so
   * returns TRUE. This is the callback method for the form field machine_name
   * as used in theme-settings.php for the theme Generator.
   *
   * @param $machine_name
   * @return boolean
   */
  public function themeNameExists($machine_name) {
    $result = FALSE;
    if (array_key_exists($machine_name, $this->data)) {
      $result = TRUE;
    }
    return $result;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ThemeInfo::themeNameExists public function Check if a theme name already exists. Looks in the list of themes to see if a theme name already exists, if so returns TRUE. This is the callback method for the form field machine_name as used in theme-settings.php for the theme Generator.
ThemeInfo::themeOptions public function Return list of base theme options. Looks for all themes with a base theme value of 'at_core' and returns the list. This means you cannot sub-theme a "skin" type sub-theme.
ThemeInfo::__construct public function Constructs a theme info object.