create controller adding delivery module in session
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>
|
||||
<requirement key="delivery_id">\d+</requirement>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Tools\URL;
|
||||
*/
|
||||
class DeliveryController extends BaseFrontController
|
||||
{
|
||||
public function select()
|
||||
public function select($delivery_id)
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirect(URL::getInstance()->getIndexPage());
|
||||
@@ -41,15 +41,16 @@ class DeliveryController extends BaseFrontController
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$deliveryId = $request->query->get("delivery_id");
|
||||
$deliveryModule = ModuleQuery::create()
|
||||
->filterById($delivery_id)
|
||||
->filterByActivate(1)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
if($deliveryId)
|
||||
{
|
||||
$deliveryModule = ModuleQuery::create()->findPk($deliveryId);
|
||||
|
||||
if ($deliveryModule) {
|
||||
$request->getSession()->setDelivery($deliveryId);
|
||||
}
|
||||
if ($deliveryModule) {
|
||||
$request->getSession()->setDelivery($delivery_id);
|
||||
} else {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,9 @@ class Delivery extends BaseSpecificModule
|
||||
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
if($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
|
||||
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->setRequest($this->request);
|
||||
|
||||
Reference in New Issue
Block a user