[TOOLS] Update autocode, allow for abstract entity classes, derive namespace from file rather than using 'get_declared_classes'
This commit is contained in:
parent
e3bfb1ebc5
commit
4736146b80
|
@ -20,26 +20,23 @@ const types = [
|
||||||
'text' => 'string',
|
'text' => 'string',
|
||||||
'varchar' => 'string',
|
'varchar' => 'string',
|
||||||
'phone_number' => 'PhoneNumber',
|
'phone_number' => 'PhoneNumber',
|
||||||
|
'float' => 'float', // TODO REMOVE THIS
|
||||||
];
|
];
|
||||||
|
|
||||||
$files = array_merge(glob(ROOT . '/src/Entity/*.php'),
|
$files = array_merge(glob(ROOT . '/src/Entity/*.php'),
|
||||||
array_merge(glob(ROOT . '/components/*/Entity/*.php'),
|
array_merge(glob(ROOT . '/components/*/Entity/*.php'),
|
||||||
glob(ROOT . '/plugins/*/Entity/*.php')));
|
glob(ROOT . '/plugins/*/Entity/*.php')));
|
||||||
|
|
||||||
$classes = [];
|
|
||||||
$nullable_no_defaults_warning = [];
|
$nullable_no_defaults_warning = [];
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$declared = get_declared_classes();
|
$class = str_replace(['/', 'src', 'components', 'plugins'], ['\\', 'App', 'Component', 'Plugin'], substr($file, strlen(ROOT) + 1, -4));
|
||||||
foreach ($declared as $dc) {
|
|
||||||
if (preg_match('/(App|(Component|Plugin)\\\\[^\\\\]+)\\\\Entity/', $dc) && !in_array($dc, $classes)) {
|
if (!method_exists($class, 'schemaDef')) {
|
||||||
$class = $dc;
|
continue;
|
||||||
$classes[] = $class;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$no_ns_class = preg_replace('/.*?\\\\/', '', $class);
|
$no_ns_class = preg_replace('/.*?\\\\/', '', $class);
|
Loading…
Reference in New Issue
Block a user