Skip to content

Commit 6c628a9

Browse files
committed
installer wip
1 parent f5c016f commit 6c628a9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Core/Installer.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,41 @@ public function installModels($directory = 'Models', $modelList = [], $flags = n
152152

153153
return false;
154154
}
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);
155180

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+
}
156190
/**
157191
* Requires the specified folder / model combination and calls
158192
* its install function.

0 commit comments

Comments
 (0)