FEATURE: delete all template paths from template_path table on template uninstall
This commit is contained in:
+13
-8
@@ -83,20 +83,24 @@ class Module extends Model
|
|||||||
*
|
*
|
||||||
* @throws \ErrorException
|
* @throws \ErrorException
|
||||||
*/
|
*/
|
||||||
public function uninstall() {
|
public function uninstall()
|
||||||
|
{
|
||||||
// check if user does not want to install module in runtime
|
// check if user does not want to install module in runtime
|
||||||
if (!App::runningInConsole()) {
|
if (!App::runningInConsole()) {
|
||||||
throw new \ErrorException('Modules can be uninstalled only via Artisan!');
|
throw new \ErrorException('Modules can be uninstalled only via Artisan!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete everything in /resources/views/visitor
|
// delete everything in /resources/views/visitor
|
||||||
$this->deleteDirectory(resource_path('views/visitor'));
|
if ($this->is_template) {
|
||||||
$this->deleteDirectory(public_path('assets'));
|
$this->deleteDirectory(resource_path('views/visitor'));
|
||||||
|
$this->deleteDirectory(public_path('assets'));
|
||||||
|
|
||||||
$handler = $this->handler;
|
// delete all template paths
|
||||||
|
TemplatePath::getQuery()->delete();
|
||||||
|
}
|
||||||
|
|
||||||
if ($handler && is_callable([$handler, 'uninstall'])) {
|
if ($this->handler && is_callable([$this->handler, 'uninstall'])) {
|
||||||
call_user_func([$handler, 'uninstall'], $this);
|
call_user_func([$this->handler, 'uninstall'], $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->delete();
|
$this->delete();
|
||||||
@@ -109,11 +113,12 @@ class Module extends Model
|
|||||||
*
|
*
|
||||||
* @throws \ErrorException
|
* @throws \ErrorException
|
||||||
*/
|
*/
|
||||||
private function deleteDirectory($directory) {
|
private function deleteDirectory($directory)
|
||||||
|
{
|
||||||
$success = \File::deleteDirectory($directory, true);
|
$success = \File::deleteDirectory($directory, true);
|
||||||
|
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
throw new \ErrorException('Cannot delete '.$directory);
|
throw new \ErrorException('Cannot delete ' . $directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user