-
-
Notifications
You must be signed in to change notification settings - Fork 560
/
ModuleFileGenerator.php
51 lines (44 loc) · 1.13 KB
/
ModuleFileGenerator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @file
* Contains \Drupal\Console\Generator\ModuleFileGenerator.
*/
namespace Drupal\Console\Generator;
/**
* Class ModuleFileGenerator
* @package Drupal\Console\Generator
*/
class ModuleFileGenerator extends Generator
{
/**
* @param $machine_name
* @param $file_path
*/
public function generate(
$machine_name,
$file_path
) {
$dir = $file_path .'/'. $machine_name. '.module';
if (file_exists($dir)) {
if (!is_dir($dir)) {
throw new \RuntimeException(
sprintf(
'Unable to generate the .module file , it already exist at "%s"',
realpath($dir)
)
);
}
}
$parameters = array(
'machine_name' => $machine_name,
'file_path' => $file_path ,
);
if ($machine_name) {
$this->renderFile(
'module/module-file.twig',
$file_path . '/' . $machine_name . '.module',
$parameters
);
}
}
}