@@ -90,22 +90,20 @@ public function handle(): int
90
90
$ getterStub = file_get_contents ($ resourceStubsPath .'getter.default.stub ' );
91
91
$ foreignGetterStub = file_get_contents ($ resourceStubsPath .'getter.foreign.stub ' );
92
92
93
+ $ getterFunctions = '' ;
93
94
foreach ($ columns as $ _column ) {
94
- $ baseContent = substr_replace ($ baseContent ,
95
- $ this ->writeGetter ($ getterStub , $ _column ->COLUMN_NAME , camel_case ($ _column ->COLUMN_NAME )),
96
- -293 , 0 );
95
+ $ getterFunctions .= $ this ->writeGetter ($ getterStub , $ _column ->COLUMN_NAME , camel_case ($ _column ->COLUMN_NAME ));
97
96
}
98
97
98
+ $ foreignGetterFunctions = '' ;
99
99
if ($ detectForeignKeys ) {
100
100
foreach ($ foreignKeys as $ _foreignKey ) {
101
- $ baseContent = substr_replace ($ baseContent ,
102
- $ this ->writeForeignGetter ($ foreignGetterStub , $ _foreignKey ->VARIABLE_NAME , $ _foreignKey ->ENTITY_DATA_TYPE ),
103
- -20 , 0 );
101
+ $ foreignGetterFunctions .= $ this ->writeForeignGetter ($ foreignGetterStub , $ _foreignKey ->VARIABLE_NAME , $ _foreignKey ->ENTITY_DATA_TYPE );
104
102
}
105
103
}
106
104
107
- $ baseContent = str_replace (['{{ EntityName }} ' , '{{ EntityNamespace }} ' , '{{ EntityVariableName }} ' , '{{ ResourceName }} ' , '{{ ResourceNamespace }} ' ],
108
- [$ entityName , $ entityNamespace , $ entityVariableName , $ resourceName , $ resourceNamespace ],
105
+ $ baseContent = str_replace (['{{ GetterFunctions }} ' , ' {{ ForeignGetterFunctions }} ' , ' {{ EntityName }} ' , '{{ EntityNamespace }} ' , '{{ EntityVariableName }} ' , '{{ ResourceName }} ' , '{{ ResourceNamespace }} ' ],
106
+ [substr ( $ getterFunctions , 0 , - 1 ), substr ( $ foreignGetterFunctions , 0 , - 1 ), $ entityName , $ entityNamespace , $ entityVariableName , $ resourceName , $ resourceNamespace ],
109
107
$ baseContent );
110
108
111
109
file_put_contents ($ filenameWithPath , $ baseContent );
0 commit comments