[TOOLS] Update bin/generate_entity_fields script

This commit is contained in:
Hugo Sales 2020-06-30 18:19:50 +00:00 committed by Hugo Sales
parent 5eae3dc351
commit 2eab90bbb0
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
1 changed files with 14 additions and 12 deletions

View File

@ -9,24 +9,26 @@ define('ROOT', dirname(__DIR__));
require ROOT . '/vendor/autoload.php';
const types = [
'blob' => '',
'bool' => 'bool',
'char' => 'string',
'datetime' => '\DateTimeInterface',
'html' => 'string',
'int' => 'int',
'numeric' => 'float',
'serial' => 'int',
'text' => 'string',
'varchar' => 'string',
'blob' => '',
'bool' => 'bool',
'char' => 'string',
'datetime' => '\DateTimeInterface',
'timestamp' => '\DateTimeInterface',
'html' => 'string',
'int' => 'int',
'numeric' => 'float',
'serial' => 'int',
'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);
$files = glob($path . '/*.php');
foreach ($files as $file) {
require_once $file;
$declared = get_declared_classes();
@ -45,7 +47,7 @@ foreach ($files as $file) {
$fields_code[] = " private {$type} \${$field};";
$methods_code[] = " public function set{$method_name}({$type} \${$field}): self " .
"{ \$this->{$field} = \${$field}; return \$this; }" . "\n" .
" public function get{$method_name}()" . ($type !== '' ? ': ' . $type : '') .
" public function get{$method_name}()" . ($type !== '' ? ": {$type} " : ' ') .
"{ return \$this->{$field}; }" . "\n";
}