public function ThemeGeneratorTypes::cloneGenerator in AT Tools 8.3
Same name and namespace in other branches
- 8.2 at_theme_generator/src/Theme/ThemeGeneratorTypes.php \Drupal\at_theme_generator\Theme\ThemeGeneratorTypes::cloneGenerator()
Generate clone type theme.
File
- at_theme_generator/
src/ Theme/ ThemeGeneratorTypes.php, line 113
Class
- ThemeGeneratorTypes
- Generate themes by type.
Namespace
Drupal\at_theme_generator\ThemeCode
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);
}