-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateController.inc.php
More file actions
30 lines (30 loc) · 1.44 KB
/
Copy pathcreateController.inc.php
File metadata and controls
30 lines (30 loc) · 1.44 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
<?php
$res = $this->res;
$Entity = $this->Entity;
$entity = strToLower($Entity);
$timestamptable = $this->timestamptable;
$html = $this->twigParser(file_get_contents($this->path . 'controller.php'), array('entity' => $entity, 'Entity' => $Entity, 'extends' => $this->extend, 'partie' => $this->partie));
//lop for autocomplete
$autocompleteRender = '';
foreach ($res as $field => $val) {
$Field = ucfirst($field);
if (isset($val['ALIAS'])) {
if ($val['ALIAS'] == 'autocomplete') {
$autocompleteRender .= "'autocomplete$Field'=>\$EntityFunctions->getAllOfFields('$entity','$field'),";
}
}
}
//parse the html with autocomplete
if ($autocompleteRender) {
/**@var string $html */
$html = $this->twigParser($html, array('autocompleteRender' => substr($autocompleteRender, 0, -1), 'autocompleteService' => 'use App\CMService\EntityFunctions'));
//specific replacement for php for include Service
$html = str_replace('new(Request $request)', 'new(Request $request,EntityFunctions $EntityFunctions)', $html);
$html = str_replace('edit(Request $request', 'edit(Request $request,EntityFunctions $EntityFunctions', $html);
} else
$html = str_replace('¤autocompleteRender¤,', '', $html);
//create file
if ($this->input->getOption('origin')) {
$this->saveFileWithCodes('/app/src/Controller/' . $Entity . 'Controller.php', $html);
} else
file_put_contents('/app/crudmick/crud/' . $Entity . 'Controller.php', $html);