Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / drupal / console-core / src / Generator / InitGenerator.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Core\Generator\InitGenerator.
6  */
7 namespace Drupal\Console\Core\Generator;
8
9 /**
10  * Class InitGenerator
11  *
12  * @package Drupal\Console\Core\Generator
13  */
14 class InitGenerator extends Generator
15 {
16     /**
17      * {@inheritdoc}
18      */
19     public function generate(array $parameters) {
20         $userHome = $parameters['user_home'];
21         $executableName = $parameters['executable_name'];
22         $override = $parameters['override'];
23         $destination = $parameters['destination'];
24         $configParameters = $parameters['config_parameters'];
25
26         $configParameters = array_map(
27             function ($item) {
28                 if (is_bool($item)) {
29                     return $item ? 'true' : 'false';
30                 }
31                 return $item;
32             },
33             $configParameters
34         );
35
36         $configFile = $userHome . 'config.yml';
37         if ($destination) {
38             $configFile = $destination . 'config.yml';
39         }
40
41         if (file_exists($configFile) && $override) {
42             copy(
43                 $configFile,
44                 $configFile . '.old'
45             );
46         }
47
48         $this->renderFile(
49             'core/init/config.yml.twig',
50             $configFile,
51             $configParameters
52         );
53
54         if ($executableName) {
55             $parameters = [
56                 'executable' => $executableName,
57             ];
58
59             $this->renderFile(
60                 'core/autocomplete/console.rc.twig',
61                 $userHome . 'console.rc',
62                 $parameters
63             );
64
65             $this->renderFile(
66                 'core/autocomplete/console.fish.twig',
67                 $userHome . 'drupal.fish',
68                 $parameters
69             );
70         }
71     }
72 }