Delete a module when module directory is missing is now possible.
This commit is contained in:
@@ -34,6 +34,7 @@ use Thelia\Model\Map\ModuleTableMap;
|
|||||||
use Thelia\Model\ModuleQuery;
|
use Thelia\Model\ModuleQuery;
|
||||||
use Thelia\Module\BaseModule;
|
use Thelia\Module\BaseModule;
|
||||||
use Thelia\Core\Event\UpdatePositionEvent;
|
use Thelia\Core\Event\UpdatePositionEvent;
|
||||||
|
use Thelia\Log\Tlog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Module
|
* Class Module
|
||||||
@@ -76,7 +77,9 @@ class Module extends BaseAction implements EventSubscriberInterface
|
|||||||
throw new \LogicException('can not instanciante this module: the namespace is null. Maybe the model is not loaded ?');
|
throw new \LogicException('can not instanciante this module: the namespace is null. Maybe the model is not loaded ?');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$reflected = new \ReflectionClass($module->getFullNamespace());
|
$reflected = new \ReflectionClass($module->getFullNamespace());
|
||||||
|
|
||||||
$instance = $reflected->newInstance();
|
$instance = $reflected->newInstance();
|
||||||
$instance->setContainer($this->container);
|
$instance->setContainer($this->container);
|
||||||
|
|
||||||
@@ -86,6 +89,12 @@ class Module extends BaseAction implements EventSubscriberInterface
|
|||||||
|
|
||||||
$fs = new Filesystem();
|
$fs = new Filesystem();
|
||||||
$fs->remove($path);
|
$fs->remove($path);
|
||||||
|
}
|
||||||
|
catch (\ReflectionException $ex) {
|
||||||
|
// Happens mostly because the module directory has been deleted.
|
||||||
|
// Log a warning, and delete the database entry.
|
||||||
|
Tlog::getInstance()->addWarning("Failed to create instance of module ", $module->getCode());
|
||||||
|
}
|
||||||
|
|
||||||
$module->delete($con);
|
$module->delete($con);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user