@@ -90,22 +90,20 @@ public function handle(): int
9090 $ getterStub = file_get_contents ($ resourceStubsPath .'getter.default.stub ' );
9191 $ foreignGetterStub = file_get_contents ($ resourceStubsPath .'getter.foreign.stub ' );
9292
93+ $ getterFunctions = '' ;
9394 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 ));
9796 }
9897
98+ $ foreignGetterFunctions = '' ;
9999 if ($ detectForeignKeys ) {
100100 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 );
104102 }
105103 }
106104
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 ],
109107 $ baseContent );
110108
111109 file_put_contents ($ filenameWithPath , $ baseContent );
0 commit comments