From 98a5b89e429d9d9c498a03357a6de92d5b9ebce6 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 29 Mar 2020 13:16:32 +0000 Subject: [PATCH] [TOOLS] Add script used to port from old class files to entities --- bin/port_entities | 111 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 bin/port_entities diff --git a/bin/port_entities b/bin/port_entities new file mode 100755 index 0000000000..3486d6b48b --- /dev/null +++ b/bin/port_entities @@ -0,0 +1,111 @@ +#!/bin/php + +. + */ +'; + +foreach ($classes as $cls) { + $ref = new ReflectionClass($cls); + + $class_name = Common::toCamelCase($cls); + $file = $ref->getFileName(); + $class_comment = $ref->getDocComment(); + $table_name = $ref->getDefaultProperties()['__table']; + $sd = $ref->getMethod('schemaDef'); + $start = $sd->getStartLine(); + $end = $sd->getEndLine(); + $command = "sed -rn '" . implode('; ', + [ + "s%(return array\\()%\\1\\ + \"name\" => \"{$table_name}\",%", + 's%schemaDef\(\)%schemaDef(): array%', + "{$start},{$end}p", + ]) . "' {$file}"; + + // echo $command . "\n"; + + $schemaDef = []; + exec($command, $schemaDef); + $schemaDef = implode("\n", $schemaDef); + + $class = "