@@ -152,7 +152,41 @@ public function installModels($directory = 'Models', $modelList = [], $flags = n
152
152
153
153
return false ;
154
154
}
155
+ public function uninstallModel ($ folder , $ name , $ flags = null )
156
+ {
157
+ Debug::log ('Uninstalling Model: ' . $ name );
158
+ $ docroot = Docroot::getLocation ('models ' , $ name , $ folder );
159
+ if ($ docroot ->error ) {
160
+ Issue::error ("$ name was not installed: $ docroot ->errorString " );
161
+ return false ;
162
+ }
163
+ $ errors = null ;
164
+ require_once $ docroot ->fullPath ;
165
+ $ node = self ::getNode ($ name );
166
+ if ($ node === false ) {
167
+ Debug::error ('Cannot uninstall model that has not been installed. ' );
168
+ return false ;
169
+ }
170
+ if (method_exists ($ docroot ->className , 'uninstall ' )) {
171
+ if (!call_user_func_array ([$ docroot ->className , 'uninstall ' ], [])) {
172
+ $ errors [] = ['errorInfo ' => "$ name failed to execute $ Type properly. " ];
173
+ $ modelInfo = array_merge ($ modelInfo , [$ Type => 'error ' ]);
174
+ } else {
175
+ $ modelInfo = array_merge ($ modelInfo , [$ Type => 'success ' ]);
176
+ }
177
+ }
178
+
179
+ self ::setNode ($ name , $ modelInfo , true );
155
180
181
+ if ($ errors !== null ) {
182
+ self ::$ errors = array_merge (self ::$ errors , $ errors );
183
+ Issue::notice ("$ name did not install properly. " );
184
+ return false ;
185
+ }
186
+
187
+ Issue::success ("$ name has been installed. " );
188
+ return true ;
189
+ }
156
190
/**
157
191
* Requires the specified folder / model combination and calls
158
192
* its install function.
0 commit comments