13 $this->originalString = $yumlString;
17 private function getFkName($table, $prefix =
"id") {
18 return $prefix . \ucfirst ( $table );
23 $this->parts = \preg_split (
'@\ *?,\ *?@', $str );
24 foreach ( $this->parts as $part ) {
32 \preg_match_all (
'@\[\w+[\|\]]@', $part, $matches );
33 if (\
sizeof ( $matches [0] ) > 0) {
34 foreach ( $matches [0] as $match ) {
35 $table = \substr ( $match, 1, \strlen ( $match ) - 2 );
36 $this->tables [$table] = [ ];
42 $tables = \array_keys ( $this->tables );
44 $matchProperties = [ ];
45 \preg_match (
'@\[' . $table .
'\|(.*?)\]@', $this->originalString, $matchProperties );
46 if (isset ( $matchProperties [1] )) {
47 $properties = $matchProperties [1];
60 $properties = \explode (
";", $propertiesString );
61 foreach ( $properties as $property ) {
63 if (! isset ( $this->tables [$table] [
"properties"] ))
64 $this->tables [$table] [
"properties"] = [ ];
65 $this->tables [$table] [
"properties"] [] = $result;
72 \preg_match_all (
'@«(.+?)»@', $property, $matches );
73 if (is_array ( $matches )) {
74 foreach ( $matches as $match ) {
75 if (isset ( $match [0] )) {
76 $property = \str_replace ( $match [0],
"", $property );
78 case $this->stereotypes [
"pk"] :
79 $result [
"pk"] =
true;
81 case $this->stereotypes [
"null"] :
82 $result [
"null"] =
true;
87 $parts = \explode (
":", $property );
88 \preg_match (
'@\ *?(\w+)@',
$parts [0], $match );
89 if (isset ( $match [1] ))
90 $result [
"name"] = $match [1];
91 if (isset (
$parts [1] )) {
92 $result [
"type"] =
$parts [1];
101 foreach ( $this->tables [$table] [
"properties"] as $property ) {
102 if (! isset ( $result ))
103 $result = $property [
"name"];
104 if (isset ( $property [
"pk"] ) && $property [
"pk"])
105 return $property [
"name"];
111 foreach ( $this->tables [$table] [
"properties"] as $property ) {
112 if ($property [
"name"] === $fieldName)
113 return $property [
"type"];
120 foreach ( $this->tables [$table] [
"properties"] as $property ) {
121 if (isset ( $property [
"pk"] ) && $property [
"pk"])
122 $result [] = $property [
"name"];
129 \preg_match_all (
'@\[' . $table .
'\][^,]*?1-.*?\[(\w+)\]@', $this->originalString, $matches );
131 \preg_match_all (
'@\[(\w+)\].*?-[^,]*?1\[' . $table .
'\]@', $this->originalString, $matches );
136 if (\
sizeof ( $matches ) > 1) {
139 foreach ( $matches [1] as $match ) {
142 $this->tables [$table] [
"relations"] [] = [
"TABLE_NAME" => $tableName,
"COLUMN_NAME" => $fk ];
150 \preg_match_all (
'@\[' . $table .
'\][^,]*?\*-.*?\*\[(\w+)\]@', $this->originalString, $matches );
156 $myFk = $this->
getFkName ( $table, $myPk );
158 if (\
sizeof ( $matches ) > 1) {
159 foreach ( $matches [1] as $match ) {
163 $fk = $this->
getFkName ( $tableName, $pk );
165 $newTable = $table .
"_" . $tableName;
166 $this->tables [$newTable] = [ ];
167 $this->tables [$newTable] [
"properties"] [] = [
"name" => $myFk,
"type" => $myFkType,
"pk" => true ];
168 $this->tables [$newTable] [
"properties"] [] = [
"name" => $fk,
"type" => $fkType,
"pk" => true ];
169 $this->tables [$tableName] [
"relations"] [] = [
"TABLE_NAME" => $newTable,
"COLUMN_NAME" => $fk ];
170 $this->tables [$table] [
"relations"] [] = [
"TABLE_NAME" => $newTable,
"COLUMN_NAME" => $myFk ];
185 return \array_keys ( $this->tables );
189 return $this->tables [$table] [
"properties"];
193 if (isset ( $this->tables [$table] [
"relations"] ))
194 return $this->tables [$table] [
"relations"];
_parseRelations($table, $matches)
parseProperties($propertiesString, $table)
_parseManyRelations($table, $matches)
getFkName($table, $prefix="id")
parseManyRelations($table)
getFieldType($table, $fieldName)