[TOOLS] Update bin/generate_entity_fields script
This commit is contained in:
parent
5eae3dc351
commit
2eab90bbb0
@ -9,24 +9,26 @@ define('ROOT', dirname(__DIR__));
|
|||||||
require ROOT . '/vendor/autoload.php';
|
require ROOT . '/vendor/autoload.php';
|
||||||
|
|
||||||
const types = [
|
const types = [
|
||||||
'blob' => '',
|
'blob' => '',
|
||||||
'bool' => 'bool',
|
'bool' => 'bool',
|
||||||
'char' => 'string',
|
'char' => 'string',
|
||||||
'datetime' => '\DateTimeInterface',
|
'datetime' => '\DateTimeInterface',
|
||||||
'html' => 'string',
|
'timestamp' => '\DateTimeInterface',
|
||||||
'int' => 'int',
|
'html' => 'string',
|
||||||
'numeric' => 'float',
|
'int' => 'int',
|
||||||
'serial' => 'int',
|
'numeric' => 'float',
|
||||||
'text' => 'string',
|
'serial' => 'int',
|
||||||
'varchar' => 'string',
|
'text' => 'string',
|
||||||
|
'varchar' => 'string',
|
||||||
];
|
];
|
||||||
|
|
||||||
$path = Yaml::parseFile(ROOT . '/config/services.yaml')['services']['app.util.schemadef_driver']['arguments'][0];
|
$path = Yaml::parseFile(ROOT . '/config/services.yaml')['services']['app.core.schemadef_driver']['arguments'][0];
|
||||||
$path = str_replace('%kernel.project_dir%', ROOT, $path);
|
$path = str_replace('%kernel.project_dir%', ROOT, $path);
|
||||||
|
|
||||||
$files = glob($path . '/*.php');
|
$files = glob($path . '/*.php');
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$declared = get_declared_classes();
|
$declared = get_declared_classes();
|
||||||
@ -45,7 +47,7 @@ foreach ($files as $file) {
|
|||||||
$fields_code[] = " private {$type} \${$field};";
|
$fields_code[] = " private {$type} \${$field};";
|
||||||
$methods_code[] = " public function set{$method_name}({$type} \${$field}): self " .
|
$methods_code[] = " public function set{$method_name}({$type} \${$field}): self " .
|
||||||
"{ \$this->{$field} = \${$field}; return \$this; }" . "\n" .
|
"{ \$this->{$field} = \${$field}; return \$this; }" . "\n" .
|
||||||
" public function get{$method_name}()" . ($type !== '' ? ': ' . $type : '') .
|
" public function get{$method_name}()" . ($type !== '' ? ": {$type} " : ' ') .
|
||||||
"{ return \$this->{$field}; }" . "\n";
|
"{ return \$this->{$field}; }" . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user