Skip to content
Snippets Groups Projects
Commit 5f513f78 authored by Vladimir Roudakov's avatar Vladimir Roudakov Committed by Vladimir Roudakov
Browse files

Issue #3123296 by VladimirAus: Error copying new subtheme via interface and enabling it

parent c651912b
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,13 @@ description: 'SUBTHEME subtheme'
core: 8.x
base theme: bootstrap4
# Stylesheets.
stylesheets-remove:
- '@bootstrap4/css/styles.css'
# Libraries.
libraries-override:
bootstrap4/global-styling: SUBTHEME/global-styling
libraries:
- SUBTHEME/global-styling
# Regions.
regions:
......
......@@ -202,7 +202,7 @@ function bootstrap4_form_system_theme_settings_subtheme_validate(array &$form, F
// Check for writable path.
$directory = DRUPAL_ROOT . '/' . $form_state->getValue('subtheme_folder');
if (\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS) === FALSE) {
$form_state->setErrorByName('subtheme_folder', t('Subtheme cannot be created.'));
$form_state->setErrorByName('subtheme_folder', t('Subtheme cannot be created. Check permissions.'));
}
// Check for common theme names.
if (in_array($form_state->getValue('subtheme_machine_name'), [
......@@ -237,6 +237,9 @@ function bootstrap4_form_system_theme_settings_subtheme_submit($form, FormStateI
$themeMName = $form_state->getValue('subtheme_machine_name');
$themePath = $drupalRoot . '/' . $form_state->getValue('subtheme_folder') . '/' . $themeMName;
$fs->mirror(drupal_get_path('theme', 'bootstrap4') . '/_SUBTHEME', $themePath);
// Copy CSS file replace empty one.
// Will be replaced after SCSS compilation is done.
$fs->copy(drupal_get_path('theme', 'bootstrap4') . '/css/style.css', $themePath . '/css/style.css', TRUE);
$files = [
'SUBTHEME.info' => $themeMName . '.info.yml',
......@@ -248,7 +251,8 @@ function bootstrap4_form_system_theme_settings_subtheme_submit($form, FormStateI
$infoYml = Yaml::decode(file_get_contents($themePath . '/' . $before));
$infoYml['name'] = $themeName;
$infoYml['description'] = $themeName . ' subtheme based on Bootstrap 4 theme.';
$infoYml['libraries-override']['bootstrap4/global-styling'] = $themeMName . '/global-styling';
$infoYml['libraries'] = [];
$infoYml['libraries'][] = $themeMName . '/global-styling';
$fs->dumpFile($themePath . '/' . $after, Yaml::encode($infoYml));
}
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment