Uses new helper functions
This commit is contained in:
@@ -50,9 +50,8 @@ class Module extends BaseAction implements EventSubscriberInterface
|
|||||||
public function toggleActivation(ModuleToggleActivationEvent $event)
|
public function toggleActivation(ModuleToggleActivationEvent $event)
|
||||||
{
|
{
|
||||||
if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) {
|
if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) {
|
||||||
$moduleClass = new \ReflectionClass($module->getFullNamespace());
|
|
||||||
|
|
||||||
$moduleInstance = $moduleClass->newInstance();
|
$moduleInstance = $module->createInstance();
|
||||||
|
|
||||||
if ( method_exists($moduleInstance, 'setContainer')) {
|
if ( method_exists($moduleInstance, 'setContainer')) {
|
||||||
$moduleInstance->setContainer($this->container);
|
$moduleInstance->setContainer($this->container);
|
||||||
@@ -85,12 +84,11 @@ class Module extends BaseAction implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$reflected = new \ReflectionClass($module->getFullNamespace());
|
$instance = $module->createInstance();
|
||||||
|
|
||||||
$instance = $reflected->newInstance();
|
|
||||||
$instance->setContainer($this->container);
|
$instance->setContainer($this->container);
|
||||||
|
|
||||||
$path = dirname($reflected->getFileName());
|
$path = $module->getAbsoluteBaseDir();
|
||||||
|
|
||||||
$instance->destroy($con, $event->getDeleteData());
|
$instance->destroy($con, $event->getDeleteData());
|
||||||
|
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ class ModuleActivateCommand extends BaseModuleGenerate
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
$moduleInstance = $module->createInstance();
|
||||||
|
|
||||||
$moduleInstance = $moduleReflection->newInstance();
|
|
||||||
|
|
||||||
$moduleInstance->activate();
|
$moduleInstance->activate();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ class ModuleDeactivateCommand extends BaseModuleGenerate
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
$moduleInstance = $module->createInstance();
|
||||||
|
|
||||||
$moduleInstance = $moduleReflection->newInstance();
|
|
||||||
|
|
||||||
$moduleInstance->deActivate();
|
$moduleInstance->deActivate();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ class OrderDelivery extends BaseForm
|
|||||||
if (null === $module) {
|
if (null === $module) {
|
||||||
$context->addViolation(Translator::getInstance()->trans("Delivery module ID not found"));
|
$context->addViolation(Translator::getInstance()->trans("Delivery module ID not found"));
|
||||||
} else {
|
} else {
|
||||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
if (! $module->isDeliveryModule()) {
|
||||||
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
|
|
||||||
$context->addViolation(
|
$context->addViolation(
|
||||||
sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\Module\DeliveryModuleInterface"), $module->getCode())
|
sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\Module\DeliveryModuleInterface"), $module->getCode())
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ class OrderPayment extends BaseForm
|
|||||||
$context->addViolation("Payment module ID not found");
|
$context->addViolation("Payment module ID not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
if (! $module->isPayementModule()) {
|
||||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
|
||||||
$context->addViolation(
|
$context->addViolation(
|
||||||
sprintf(Translator::getInstance()->trans("payment module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode())
|
sprintf(Translator::getInstance()->trans("payment module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode())
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user