2523822c06b2843e9316d42b802177d7209bc3c6
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_7 / Theme.php
1 <?php
2
3 namespace DrupalCodeGenerator\Command\Drupal_7;
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 d7:theme command.
13  */
14 class Theme extends BaseGenerator {
15
16   protected $name = 'd7:theme';
17   protected $description = 'Generates Drupal 7 theme';
18   protected $destination = 'themes';
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function interact(InputInterface $input, OutputInterface $output) {
24     $questions['name'] = new Question('Theme name');
25     $questions['name']->setValidator([Utils::class, 'validateRequired']);
26     $questions['machine_name'] = new Question('Theme machine name');
27     $questions['machine_name']->setValidator([Utils::class, 'validateMachineName']);
28     $questions['description'] = new Question('Theme description', 'A simple Drupal 7 theme.');
29     $questions['base_theme'] = new Question('Base theme');
30
31     $vars = &$this->collectVars($input, $output, $questions);
32     $vars['asset_name'] = str_replace('_', '-', $vars['machine_name']);
33
34     $this->addFile()
35       ->path('{machine_name}/{machine_name}.info')
36       ->template('d7/theme-info.twig');
37
38     $this->addFile()
39       ->path('{machine_name}/template.php')
40       ->template('d7/template.php.twig');
41
42     $this->addFile()
43       ->path('{machine_name}/js/{asset_name}.js')
44       ->template('d7/javascript.twig');
45
46     $this->addFile()
47       ->path('{machine_name}/css/{asset_name}.css')
48       ->content('');
49
50     $this->addDirectory()
51       ->path('{machine_name}/templates');
52
53     $this->addDirectory()
54       ->path('{machine_name}/images');
55   }
56
57 }