View source
<?php
namespace Drupal\at_theme_generator\Theme;
class ThemeGeneratorTypes extends ThemeGenerator {
public function starterkitGenerator() {
$this
->copySource();
$yml_files = [
'shortcodes',
'libraries',
'info',
];
$this
->renameYmlFiles($yml_files);
$this
->rewriteLibrariesYml('VERSION_STRING');
$this
->renameThemeFile();
$this
->rewriteThemeFile('HOOK');
if ($this->theme_settings_file === 0) {
$this
->removeThemeSettingsFile();
}
else {
$this
->rewriteThemeSettingsFile('HOOK');
}
$this
->renameConfigFiles();
$this
->rewriteConfigFiles();
if ($this->block_config === 0) {
$this
->removeConfigFiles();
}
$this
->rewritePageLayoutCSS();
$this
->renameGeneratedCssFiles();
$this
->rewritePageTemplateLibrary();
if ($this->templates === 1) {
$this
->copyTemplates();
}
if ($this->color === 0) {
$this
->removeColorDirectory();
}
$this
->removeUnusedLayout();
$this
->renameLayouts();
$this
->rewriteUikitPartials();
if ($this->scss === 0) {
$this
->removeCssSourceMaps();
$this
->removeCssSourceMappingURL();
$this
->removeScss();
$this
->removeScssTools();
}
$base_theme_original = isset($this->base_theme_info['version']) ? $this->base_theme_info['version'] : 'git-dev';
$desc['text'] = $this->description ?: '';
$desc['base'] = 'at_core (' . $base_theme_original . ')';
$desc['time'] = $this->datetime;
$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);
}
public function cloneGenerator() {
$this
->copySource();
$yml_files = [
'shortcodes',
'libraries',
'info',
];
$this
->renameYmlFiles($yml_files);
if ($this->info['subtheme type'] === 'adaptive_subtheme') {
$this
->renameThemeFile();
$this
->rewriteThemeFile($this->source['name']);
$this
->rewriteThemeSettingsFile($this->source['name']);
$this
->renameConfigFiles();
$this
->rewriteConfigFiles();
$this
->replaceCloneConfigSettings();
$this
->renameGeneratedCssFiles();
$this
->rewritePageTemplateLibrary();
}
else {
$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];
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['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'];
if (isset($this->info['tags']) && !empty($this->info['tags'])) {
$info['tags'] = $this->info['tags'];
}
if (isset($this->info['libraries']) && !empty($this->info['libraries'])) {
$info['libraries'] = $this->info['libraries'];
}
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',
];
}
}
if (isset($this->info['stylesheets-remove']) && !empty($this->info['stylesheets-remove'])) {
$info['stylesheets-remove'] = $this->info['stylesheets-remove'];
}
if (isset($this->info['features']) && !empty($this->info['features'])) {
$info['features'] = $this->info['features'];
}
$this
->infoYml($info);
}
public function skinGenerator() {
$this
->copySource();
$yml_files = [
'libraries',
'info',
];
$this
->renameYmlFiles($yml_files);
$this
->processSkinStyles('SKIN');
$skin_base_path = drupal_get_path('theme', $this->skin_base);
if (!file_exists($skin_base_path . '/Gruntfile.js')) {
$this
->removeScss();
$this
->removeScssTools();
}
$this
->replaceSkinLogos();
$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['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);
}
}