You are here

class ThemeGeneratorTypes in AT Tools 8.3

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

Generate themes by type.

Hierarchy

Expanded class hierarchy of ThemeGeneratorTypes

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

File

at_theme_generator/src/Theme/ThemeGeneratorTypes.php, line 8

Namespace

Drupal\at_theme_generator\Theme
View source
class ThemeGeneratorTypes extends ThemeGenerator {

  /**
   * Generate starter kit type theme.
   */
  public function starterkitGenerator() {

    // Copy source.
    $this
      ->copySource();

    // Yml files.
    $yml_files = [
      'shortcodes',
      'libraries',
      'info',
    ];
    $this
      ->renameYmlFiles($yml_files);

    // Replace the version string in libraries.yml.
    $this
      ->rewriteLibrariesYml('VERSION_STRING');

    // [theme_name].theme.
    $this
      ->renameThemeFile();
    $this
      ->rewriteThemeFile('HOOK');

    // theme-settings.php
    if ($this->theme_settings_file === 0) {
      $this
        ->removeThemeSettingsFile();
    }
    else {
      $this
        ->rewriteThemeSettingsFile('HOOK');
    }

    // Config.
    $this
      ->renameConfigFiles();
    $this
      ->rewriteConfigFiles();
    if ($this->block_config === 0) {
      $this
        ->removeConfigFiles();
    }

    // Generated CSS files.
    $this
      ->rewritePageLayoutCSS();
    $this
      ->renameGeneratedCssFiles();

    // Templates.
    $this
      ->rewritePageTemplateLibrary();
    if ($this->templates === 1) {
      $this
        ->copyTemplates();
    }

    // Color.
    if ($this->color === 0) {
      $this
        ->removeColorDirectory();
    }

    // Remove/rename page layouts & layout_plugin.
    $this
      ->removeUnusedLayout();
    $this
      ->renameLayouts();
    $this
      ->rewriteUikitPartials();

    // Remove SCSS.
    if ($this->scss === 0) {
      $this
        ->removeCssSourceMaps();
      $this
        ->removeCssSourceMappingURL();
      $this
        ->removeScss();
      $this
        ->removeScssTools();
    }

    // Base theme original - version.
    $base_theme_original = isset($this->base_theme_info['version']) ? $this->base_theme_info['version'] : 'git-dev';

    // Description
    $desc['text'] = $this->description ?: '';
    $desc['base'] = 'at_core (' . $base_theme_original . ')';
    $desc['time'] = $this->datetime;

    // Info
    $info['name'] = "{$this->friendly_name}";
    $info['version'] = $this->version;
    $info['type'] = "theme";
    $info['base theme'] = 'at_core';
    $info['base theme original'] = $base_theme_original;
    $info['subtheme type'] = 'adaptive_subtheme';
    $info['layout'] = $this->layout_library;
    $info['description'] = $this
      ->infoYmlDescription($desc);
    $info['core'] = '8.x';
    $info['regions'] = $this->info['regions'];
    $info['tags'] = 'adaptivetheme sub-theme';
    $info['libraries-extend'] = [
      'quickedit/quickedit' => [
        $this->machine_name . '/quickedit',
      ],
    ];
    $info['stylesheets-remove'] = [
      '@stable/css/node/node.preview.css',
      '@stable/css/node/node.module.css',
      '@stable/css/views/views.module.css',
      '@stable/css/system/components/tablesort.module.css',
      '@classy/css/components/file.css',
    ];
    $info['features'] = [
      'logo',
      'favicon',
      'node_user_picture',
      'comment_user_picture',
      'comment_user_verification',
    ];
    $this
      ->infoYml($info);
  }

  /**
   * Generate clone type theme.
   */
  public function cloneGenerator() {

    // Copy source.
    $this
      ->copySource();

    // Yml files.
    $yml_files = [
      'shortcodes',
      'libraries',
      'info',
    ];
    $this
      ->renameYmlFiles($yml_files);
    if ($this->info['subtheme type'] === 'adaptive_subtheme') {

      // [theme_name].theme.
      $this
        ->renameThemeFile();
      $this
        ->rewriteThemeFile($this->source['name']);

      // theme-settings.php
      $this
        ->rewriteThemeSettingsFile($this->source['name']);

      // Config.
      $this
        ->renameConfigFiles();
      $this
        ->rewriteConfigFiles();
      $this
        ->replaceCloneConfigSettings();

      // Generated CSS files.
      $this
        ->renameGeneratedCssFiles();

      // Templates.
      $this
        ->rewritePageTemplateLibrary();
    }
    else {

      // Stylesheets and library.
      $this
        ->processSkinStyles($this->source['name']);
    }
    $clone_quotes = [
      'The shroud of the Dark Side has fallen. Begun, this clone war has.',
      'Blind we are, if creation of this clone army we could not see.',
      'The first step to correcting a mistake is patience.',
      'A single chance is a galaxy of hope.',
      'A very wise jedi once said nothing happens by accident.',
      'Smaller in number we are but larger in mind.',
    ];
    $cq = array_rand($clone_quotes);
    $clone_quote = $clone_quotes[$cq];

    // Description
    if (!empty($this->description)) {
      $desc_text = $this->description;
    }
    else {
      $desc_text = '<em>' . $clone_quote . '</em>';
    }
    $desc['text'] = $desc_text;
    $desc['base'] = $this->info['base theme'] . ' (' . $this->info['base theme original'] . ')';
    $desc['time'] = $this->datetime;
    $desc['clone'] = $this->source['name'];

    // Info
    $info['name'] = "{$this->friendly_name}";
    $info['version'] = $this->version;
    $info['type'] = "theme";
    $info['base theme'] = $this->info['base theme'];
    $info['base theme original'] = $this->info['base theme original'];
    $info['subtheme type'] = $this->info['subtheme type'];
    $info['layout'] = $this->info['layout'];
    $info['description'] = $this
      ->infoYmlDescription($desc);
    $info['core'] = '8.x';
    $info['regions'] = $this->info['regions'];

    // Tags.
    if (isset($this->info['tags']) && !empty($this->info['tags'])) {
      $info['tags'] = $this->info['tags'];
    }

    // Libraries.
    if (isset($this->info['libraries']) && !empty($this->info['libraries'])) {
      $info['libraries'] = $this->info['libraries'];
    }

    // Libraries extend.
    if (isset($this->info['libraries-extend']) && !empty($this->info['libraries-extend'])) {
      $info['libraries-extend'] = $this->info['libraries-extend'];
      if (isset($info['libraries-extend']['quickedit/quickedit'])) {
        $info['libraries-extend']['quickedit/quickedit'] = [
          $this->machine_name . '/quickedit',
        ];
      }
    }

    // Stylesheets remove.
    if (isset($this->info['stylesheets-remove']) && !empty($this->info['stylesheets-remove'])) {
      $info['stylesheets-remove'] = $this->info['stylesheets-remove'];
    }

    // Features.
    if (isset($this->info['features']) && !empty($this->info['features'])) {
      $info['features'] = $this->info['features'];
    }
    $this
      ->infoYml($info);
  }

  /**
   * Generate skin type theme.
   */
  public function skinGenerator() {

    // Copy source.
    $this
      ->copySource();

    // Yml files.
    $yml_files = [
      'libraries',
      'info',
    ];
    $this
      ->renameYmlFiles($yml_files);

    // Stylesheets and library.
    $this
      ->processSkinStyles('SKIN');

    // Remove SCSS if base theme does not support it.
    $skin_base_path = drupal_get_path('theme', $this->skin_base);
    if (!file_exists($skin_base_path . '/Gruntfile.js')) {
      $this
        ->removeScss();
      $this
        ->removeScssTools();
    }

    // Logos
    $this
      ->replaceSkinLogos();

    // Description
    $desc['text'] = $this->description;
    $desc['base'] = $this->skin_base . ' (' . $this->base_theme_info['base theme original'] . ')';
    $desc['time'] = $this->datetime;
    $desc['skin'] = $this->skin_base;

    // Info
    $info['name'] = "{$this->friendly_name}";
    $info['version'] = $this->version;
    $info['type'] = "theme";
    $info['base theme'] = $this->skin_base;
    $info['base theme original'] = $this->base_theme_info['base theme original'];
    $info['subtheme type'] = 'adaptive_skin';
    $info['layout'] = $this->base_theme_info['layout'];
    $info['description'] = $this
      ->infoYmlDescription($desc);
    $info['core'] = '8.x';
    $info['regions'] = $this->base_theme_info['regions'];
    $info['tags'] = 'adaptivetheme sub-theme';
    $info['features'] = $this->info['features'];
    $info['libraries'] = [
      $this->machine_name . '/skin',
    ];
    $this
      ->infoYml($info);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ThemeGenerator::$at_generator_path protected property
ThemeGenerator::$block_config protected property
ThemeGenerator::$clone_source protected property
ThemeGenerator::$color protected property
ThemeGenerator::$config protected property
ThemeGenerator::$datetime protected property
ThemeGenerator::$description protected property
ThemeGenerator::$dir_option protected property
ThemeGenerator::$friendly_name protected property
ThemeGenerator::$generic_description protected property
ThemeGenerator::$machine_name protected property Protected variables.
ThemeGenerator::$path protected property
ThemeGenerator::$scss protected property
ThemeGenerator::$skin_base protected property
ThemeGenerator::$source protected property
ThemeGenerator::$sub_theme_type protected property
ThemeGenerator::$target protected property
ThemeGenerator::$templates protected property
ThemeGenerator::$theme_settings_file protected property
ThemeGenerator::$version protected property
ThemeGenerator::copySource public function Copy the source theme to the target location.
ThemeGenerator::copyTemplates public function Copy base theme templates.
ThemeGenerator::getBaseThemeInfoYml public function Return the base themes info yml.
ThemeGenerator::getCloneSourceConfigSettings public function Get the clone source themes config from the active configuration.
ThemeGenerator::getComponentCssFiles public function Return this themes component CSS files.
ThemeGenerator::getConfig public function Return this themes source configuration files. We need to get the source themes config because the target copy may not yet exist.
ThemeGenerator::getGeneratedCssFiles public function Return this themes generated CSS files.
ThemeGenerator::getInfoYml public function Return the source themes info yml. We need to parse the source themes info yml because the target copy may not yet exist.
ThemeGenerator::getLayout public function Get layout.
ThemeGenerator::infoYml public function
ThemeGenerator::infoYmlDescription public function Format theme description.
ThemeGenerator::processSkinStyles public function Rename Skin styles & library declarations.
ThemeGenerator::removeColorDirectory public function Remove the color directory.
ThemeGenerator::removeConfigFiles public function Remove config files.
ThemeGenerator::removeCssSourceMappingURL public function Remove CSS source mapping URLs in CSS files.
ThemeGenerator::removeCssSourceMaps public function Remove CSS source map files.
ThemeGenerator::removeScss public function Remove SCSS/SASS related directories and files.
ThemeGenerator::removeScssTools public function Remove SCSS tools and related files.
ThemeGenerator::removeThemeSettingsFile public function Remove the theme-settings.php file.
ThemeGenerator::removeUnusedLayout public function Remove unused layout directory and files.
ThemeGenerator::renameConfigFiles public function Rename config files.
ThemeGenerator::renameGeneratedCssFiles public function Rename this themes generated CSS files.
ThemeGenerator::renameLayouts public function Rename layouts.
ThemeGenerator::renameThemeFile public function Rename the [theme_name].theme file.
ThemeGenerator::renameYmlFiles public function Rename .yml files.
ThemeGenerator::replaceCloneConfigSettings public function Replace the installation config with the clone sources active config.
ThemeGenerator::replaceSkinLogos public function Copy logos from the skin source/base to the skin theme.
ThemeGenerator::rewriteConfigFiles public function Rewrite config files.
ThemeGenerator::rewriteLibrariesYml public function Rewrite library versions in [theme_name].libraries.yml.
ThemeGenerator::rewritePageLayoutCSS public function Rewrite the generated layout CSS if it's a float based theme, and remove the float layout.
ThemeGenerator::rewritePageTemplateLibrary public function Rewrite Page Template Library.
ThemeGenerator::rewriteThemeFile public function Rewrite the [theme_name].theme file to replace stings.
ThemeGenerator::rewriteThemeSettingsFile public function Rewrite the theme-settings.php file to replace stings.
ThemeGenerator::rewriteUikitPartials public function Rewrite page layout include.
ThemeGenerator::sourceTheme public function Return the source theme name to use in string operations and the path to the source theme.
ThemeGenerator::targetDirectory public function Path to where we will save the theme and perform generator operations.
ThemeGenerator::__construct public function Generator constructor.
ThemeGeneratorTypes::cloneGenerator public function Generate clone type theme.
ThemeGeneratorTypes::skinGenerator public function Generate skin type theme.
ThemeGeneratorTypes::starterkitGenerator public function Generate starter kit type theme.