bfadd8d9f9ba7f4b4c17fc23980101bc925ba26f
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Theme.php
1 <?php
2
3 namespace DrupalCodeGenerator\Command\Drupal_8;
4
5 use DrupalCodeGenerator\Command\BaseGenerator;
6 use DrupalCodeGenerator\Utils;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Output\OutputInterface;
9 use Symfony\Component\Console\Question\Question;
10
11 /**
12  * Implements d8:theme command.
13  *
14  * @TODO: Create a test for this.
15  */
16 class Theme extends BaseGenerator {
17
18   protected $name = 'd8:theme';
19   protected $description = 'Generates Drupal 8 theme';
20   protected $alias = 'theme';
21   protected $destination = 'themes';
22
23   /**
24    * {@inheritdoc}
25    */
26   protected function interact(InputInterface $input, OutputInterface $output) {
27     $questions['name'] = new Question('Theme name');
28     $questions['machine_name'] = new Question('Theme machine name');
29     $questions['base_theme'] = new Question('Base theme', 'classy');
30     $questions['description'] = new Question('Description', 'A flexible theme with a responsive, mobile-first layout.');
31     $questions['package'] = new Question('Package', 'Custom');
32
33     $vars = $this->collectVars($input, $output, $questions);
34     $vars['base_theme'] = Utils::human2machine($vars['base_theme']);
35
36     $prefix = $vars['machine_name'] . '/' . $vars['machine_name'];
37
38     $this->addFile()
39       ->path($prefix . '.info.yml')
40       ->template('d8/yml/theme-info.twig');
41
42     $this->addFile()
43       ->path($prefix . '.libraries.yml')
44       ->template('d8/yml/theme-libraries.twig');
45
46     $this->addFile()
47       ->path($prefix . '.breakpoints.yml')
48       ->template('d8/yml/breakpoints.twig');
49
50     $this->addFile()
51       ->path($prefix . '.theme')
52       ->template('d8/theme.twig');
53
54     $this->addFile()
55       ->path('{machine_name}/js/' . str_replace('_', '-', $vars['machine_name']) . '.js')
56       ->template('d8/javascript.twig');
57
58     $this->addFile()
59       ->path('{machine_name}/theme-settings.php')
60       ->template('d8/theme-settings-form.twig');
61
62     $this->addFile()
63       ->path('{machine_name}/config/install/{machine_name}.settings.yml')
64       ->template('d8/theme-settings-config.twig');
65
66     $this->addFile()
67       ->path('{machine_name}/config/schema/{machine_name}.schema.yml')
68       ->template('d8/theme-settings-schema.twig');
69
70     $this->addFile()
71       ->path('{machine_name}/logo.svg')
72       ->template('d8/theme-logo.twig');
73
74     $this->addDirectory()
75       ->path('{machine_name}/templates');
76
77     $this->addDirectory()
78       ->path('{machine_name}/images');
79
80     $css_files = [
81       'base/elements.css',
82       'components/block.css',
83       'components/breadcrumb.css',
84       'components/field.css',
85       'components/form.css',
86       'components/header.css',
87       'components/menu.css',
88       'components/messages.css',
89       'components/node.css',
90       'components/sidebar.css',
91       'components/table.css',
92       'components/tabs.css',
93       'components/buttons.css',
94       'layouts/layout.css',
95       'theme/print.css',
96     ];
97     foreach ($css_files as $file) {
98       $this->addFile()
99         ->path('{machine_name}/css/' . $file)
100         ->content('');
101     }
102
103   }
104
105 }