is_template) { self::deleteDirectory(resource_path('views/visitor')); self::deleteDirectory(resource_path('views/modules')); self::deleteDirectory(public_path('assets')); // delete all template paths TemplatePath::getQuery() ->delete(); } if ($module->handler && is_callable([$module->handler, 'uninstall'])) { call_user_func([$module->handler, 'uninstall'], $module); } $module->delete(); } /** * Delete directory when uninstalling module. * * @param $directory * * @throws \ErrorException */ private static function deleteDirectory($directory) { if (!is_dir($directory)) { return; } $success = \File::deleteDirectory($directory, true); if (!$success) { throw new \ErrorException('Cannot delete ' . $directory); } } }