forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormGenerator.php
More file actions
45 lines (42 loc) · 1.23 KB
/
Copy pathFormGenerator.php
File metadata and controls
45 lines (42 loc) · 1.23 KB
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
<?php
/**
* @file
* Contains Drupal\AppConsole\Generator\FormGenerator.
*/
namespace Drupal\AppConsole\Generator;
class FormGenerator extends Generator
{
/**
* @param $module
* @param $class_name
* @param $services
* @param $inputs
* @param $form_id
* @param $update_routing
*/
public function generate($module, $class_name, $form_id, $services, $inputs, $update_routing)
{
$class_name_short = substr($class_name, -4)=='Form'?str_replace('Form', '', $class_name):$class_name;
$parameters = array(
'class_name' => $class_name,
'services' => $services,
'inputs' => $inputs,
'module_name' => $module,
'form_id' => $form_id,
'class_name_short' => strtolower($class_name_short),
);
$this->renderFile(
'module/src/Form/form.php.twig',
$this->getFormPath($module) . '/' . $class_name . '.php',
$parameters
);
if ($update_routing) {
$this->renderFile(
'module/routing-form.yml.twig',
$this->getModulePath($module) . '/' . $module . '.routing.yml',
$parameters,
FILE_APPEND
);
}
}
}