forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControllerGenerator.php
More file actions
45 lines (39 loc) · 1.27 KB
/
Copy pathControllerGenerator.php
File metadata and controls
45 lines (39 loc) · 1.27 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\ControllerGenerator.
*/
namespace Drupal\AppConsole\Generator;
class ControllerGenerator extends Generator
{
public function generate($module, $class_name, $method_name, $route, $test, $services, $class_machine_name)
{
$parameters = [
'class_name' => $class_name,
'services' => $services,
'module' => $module,
'method_name' => $method_name,
'class_machine_name' => $class_machine_name,
'route' => (strpos($route, '/') === 0) ? $route : '/' . $route,
'learning' => $this->isLearning()
];
$this->renderFile(
'module/src/Controller/controller.php.twig',
$this->getControllerPath($module) . '/' . $class_name . '.php',
$parameters
);
$this->renderFile(
'module/routing-controller.yml.twig',
$this->getModulePath($module) . '/' . $module . '.routing.yml',
$parameters,
FILE_APPEND
);
if ($test) {
$this->renderFile(
'module/Tests/Controller/controller.php.twig',
$this->getTestPath($module, 'Controller') . '/' . $class_name . 'Test.php',
$parameters
);
}
}
}