Browse Source

[TOOLS] Update autocode, allow for abstract entity classes, derive namespace from file rather than using 'get_declared_classes'

experimental
Hugo Sales 1 year ago
parent
commit
4736146b80
Signed by: someonewithpc <hugo@hsal.es> GPG Key ID: 7D0C7EAFC9D835A0
1 changed files with 5 additions and 8 deletions
  1. +5
    -8
      bin/update_autocode

bin/generate_entity_fields → bin/update_autocode View File

@@ -20,26 +20,23 @@ const types = [
'text' => 'string',
'varchar' => 'string',
'phone_number' => 'PhoneNumber',
'float' => 'float', // TODO REMOVE THIS
];

$files = array_merge(glob(ROOT . '/src/Entity/*.php'),
array_merge(glob(ROOT . '/components/*/Entity/*.php'),
glob(ROOT . '/plugins/*/Entity/*.php')));

$classes = [];
$nullable_no_defaults_warning = [];

foreach ($files as $file) {

require_once $file;

$declared = get_declared_classes();
foreach ($declared as $dc) {
if (preg_match('/(App|(Component|Plugin)\\\\[^\\\\]+)\\\\Entity/', $dc) && !in_array($dc, $classes)) {
$class = $dc;
$classes[] = $class;
break;
}
$class = str_replace(['/', 'src', 'components', 'plugins'], ['\\', 'App', 'Component', 'Plugin'], substr($file, strlen(ROOT) + 1, -4));

if (!method_exists($class, 'schemaDef')) {
continue;
}

$no_ns_class = preg_replace('/.*?\\\\/', '', $class);

Loading…
Cancel
Save