Skip to content
Snippets Groups Projects
Commit 3c01312b authored by jurgenhaas's avatar jurgenhaas
Browse files

#7 Implement base theme support

parent b4e79122
No related branches found
No related tags found
No related merge requests found
......@@ -124,7 +124,10 @@ class Handler
->getExtra() + ['theme-d8-sass' => []];
$this->options = array_replace_recursive([
'project_name' => 'mytheme',
'copy_starterkit' => true,
'base_theme' => [
'name' => 'bartik',
'import' => [],
],
'bower_assets' => [
'global' => false,
'fonts' => [],
......@@ -222,6 +225,7 @@ class Handler
if (empty($string)) {
return '';
}
$string = str_replace('THEMENAME', '{{ project_name }}', $string);
$this->twig_loader->setTemplate('fixed', $string);
return str_replace('"', '"', $this->twig->render('fixed', $this->getOptions()));
......@@ -330,18 +334,18 @@ class Handler
$finder = new Finder();
$finder->ignoreDotFiles(FALSE);
# TODO: Replace this with the base_theme settings from composer.json
# TODO: Those settings also need to go into default settings above
// Copy all files
$this->copyFiles($fs, $finder, $pluginRoot . '/templates', $destination);
if ($this->getOption('copy_starterkit')) {
// Copy Bootstrap base theme files
$bootstrapPackage = $this->getPackage('drupal/bootstrap');
if ($bootstrapPackage) {
$bootstrapRoot = $this->getInstallationManager()->getInstallPath($bootstrapPackage);
$this->copyFiles($fs, $finder, $bootstrapRoot . '/starterkits/sass', $destination);
}
// Copy all files
$this->copyFiles($fs, $finder, $pluginRoot . '/templates', $destination);
// Handle optional base theme
$baseTheme = $this->getOption('base_theme');
if (isset($baseTheme['package'])) {
$baseThemePackage = $this->getPackage($baseTheme['package']);
if ($baseThemePackage && isset($baseTheme['starterkit'])) {
$starterkitRoot = $this->getInstallationManager()->getInstallPath($baseThemePackage) . DIRECTORY_SEPARATOR . $baseTheme['starterkit'];
$this->copyFiles($fs, $finder, $starterkitRoot , $destination);
}
}
// Remove bower stuff if that's available globally
if ($this->getOption('bower_assets')['global']) {
......
core: 8.x
type: theme
base theme: bartik
base theme: {{ base_theme.name }}
name: '{{ project_name }}'
description: 'Drupal theme {{ project_name }}'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment