FEATURE: delete all template paths from template_path table on template uninstall

This commit is contained in:
Michal Kváček
2016-09-20 14:54:43 +02:00
parent e8b91db6f2
commit 39279a1633
+10 -5
View File
@@ -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
if ($this->is_template) {
$this->deleteDirectory(resource_path('views/visitor')); $this->deleteDirectory(resource_path('views/visitor'));
$this->deleteDirectory(public_path('assets')); $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,7 +113,8 @@ 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) {