Version 1
[yaffs-website] / vendor / drupal / console / src / Generator / PluginViewsFieldGenerator.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Generator\PluginFieldFormatterGenerator.
6  */
7
8 namespace Drupal\Console\Generator;
9
10 use Drupal\Console\Core\Generator\Generator;
11 use Drupal\Console\Extension\Manager;
12
13 class PluginViewsFieldGenerator extends Generator
14 {
15     /**
16      * @var Manager
17      */
18     protected $extensionManager;
19
20     /**
21      * PluginViewsFieldGenerator constructor.
22      *
23      * @param Manager $extensionManager
24      */
25     public function __construct(
26         Manager $extensionManager
27     ) {
28         $this->extensionManager = $extensionManager;
29     }
30
31     /**
32      * Generator Plugin Field Formatter.
33      *
34      * @param string $module     Module name
35      * @param string $class_name Plugin Class name
36      * @param string $label      Plugin label
37      * @param string $plugin_id  Plugin id
38      * @param string $field_type Field type this formatter supports
39      */
40     public function generate($module, $class_machine_name, $class_name, $title, $description)
41     {
42         $parameters = [
43             'module' => $module,
44             'class_machine_name' => $class_machine_name,
45             'class_name' => $class_name,
46             'title' => $title,
47             'description' => $description,
48         ];
49
50         $this->renderFile(
51             'module/module.views.inc.twig',
52             $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.views.inc',
53             $parameters
54         );
55
56         $this->renderFile(
57             'module/src/Plugin/Views/field/field.php.twig',
58             $this->extensionManager->getPluginPath($module, 'views/field') . '/' . $class_name . '.php',
59             $parameters
60         );
61     }
62 }