X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FGenerator%2FThemeGenerator.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FGenerator%2FThemeGenerator.php;h=e9f15173ced113c9e384c4feab58c51cc33463fa;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Generator/ThemeGenerator.php b/vendor/drupal/console/src/Generator/ThemeGenerator.php new file mode 100644 index 000000000..e9f15173c --- /dev/null +++ b/vendor/drupal/console/src/Generator/ThemeGenerator.php @@ -0,0 +1,108 @@ +extensionManager = $extensionManager; + } + + public function generate( + $theme, + $machine_name, + $dir, + $description, + $core, + $package, + $base_theme, + $global_library, + $regions, + $breakpoints + ) { + $dir .= '/' . $machine_name; + if (file_exists($dir)) { + if (!is_dir($dir)) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the bundle as the target directory "%s" exists but is a file.', + realpath($dir) + ) + ); + } + $files = scandir($dir); + if ($files != ['.', '..']) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the bundle as the target directory "%s" is not empty.', + realpath($dir) + ) + ); + } + if (!is_writable($dir)) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the bundle as the target directory "%s" is not writable.', + realpath($dir) + ) + ); + } + } + + $parameters = [ + 'theme' => $theme, + 'machine_name' => $machine_name, + 'type' => 'theme', + 'core' => $core, + 'description' => $description, + 'package' => $package, + 'base_theme' => $base_theme, + 'global_library' => $global_library, + 'regions' => $regions, + 'breakpoints' => $breakpoints, + ]; + + $this->renderFile( + 'theme/info.yml.twig', + $dir . '/' . $machine_name . '.info.yml', + $parameters + ); + + $this->renderFile( + 'theme/theme.twig', + $dir . '/' . $machine_name . '.theme', + $parameters + ); + + if ($breakpoints) { + $this->renderFile( + 'theme/breakpoints.yml.twig', + $dir . '/' . $machine_name . '.breakpoints.yml', + $parameters + ); + } + } +}