Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Generator / PluginTypeYamlGenerator.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Generator\PluginTypeYamlGenerator.
6  */
7
8 namespace Drupal\Console\Generator;
9
10 use Drupal\Console\Core\Generator\Generator;
11 use Drupal\Console\Extension\Manager;
12
13 class PluginTypeYamlGenerator extends Generator
14 {
15     /**
16      * @var Manager
17      */
18     protected $extensionManager;
19
20     /**
21      * PluginTypeYamlGenerator constructor.
22      *
23      * @param Manager $extensionManager
24      */
25     public function __construct(
26         Manager $extensionManager
27     ) {
28         $this->extensionManager = $extensionManager;
29     }
30
31     /**
32      * {@inheritdoc}
33      */
34     public function generate(array $parameters)
35     {
36         $module = $parameters['module'];
37         $class_name = $parameters['class_name'];
38         $plugin_file_name = $parameters['plugin_file_name'];
39
40         $moduleInstance = $this->extensionManager->getModule($module);
41         $modulePath = $moduleInstance->getPath() . '/' . $module;
42         $moduleSourcePlugin = $moduleInstance->getSourcePath() . '/' . $class_name;
43         $moduleServiceYaml = $modulePath . '.services.yml';
44         $parameters['file_exists'] = file_exists($moduleServiceYaml);
45
46         $this->renderFile(
47             'module/src/yaml-plugin-manager.php.twig',
48             $moduleSourcePlugin . 'Manager.php',
49             $parameters
50         );
51
52         $this->renderFile(
53             'module/src/yaml-plugin-manager-interface.php.twig',
54             $moduleSourcePlugin . 'ManagerInterface.php',
55             $parameters
56         );
57
58         $this->renderFile(
59             'module/plugin-yaml-services.yml.twig',
60             $moduleServiceYaml,
61             $parameters,
62             FILE_APPEND
63         );
64
65         $this->renderFile(
66             'module/plugin.yml.twig',
67             $modulePath . '.' . $plugin_file_name . '.yml',
68             $parameters
69         );
70     }
71 }