create controller adding delivery module in session
This commit is contained in:
@@ -63,6 +63,7 @@
|
|||||||
<!-- order management process -->
|
<!-- order management process -->
|
||||||
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
|
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
|
||||||
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>
|
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>
|
||||||
|
<requirement key="delivery_id">\d+</requirement>
|
||||||
</route>
|
</route>
|
||||||
<!-- end order management process -->
|
<!-- end order management process -->
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use Thelia\Tools\URL;
|
|||||||
*/
|
*/
|
||||||
class DeliveryController extends BaseFrontController
|
class DeliveryController extends BaseFrontController
|
||||||
{
|
{
|
||||||
public function select()
|
public function select($delivery_id)
|
||||||
{
|
{
|
||||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||||
$this->redirect(URL::getInstance()->getIndexPage());
|
$this->redirect(URL::getInstance()->getIndexPage());
|
||||||
@@ -41,15 +41,16 @@ class DeliveryController extends BaseFrontController
|
|||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
$deliveryId = $request->query->get("delivery_id");
|
$deliveryModule = ModuleQuery::create()
|
||||||
|
->filterById($delivery_id)
|
||||||
|
->filterByActivate(1)
|
||||||
|
->findOne()
|
||||||
|
;
|
||||||
|
|
||||||
if($deliveryId)
|
if ($deliveryModule) {
|
||||||
{
|
$request->getSession()->setDelivery($delivery_id);
|
||||||
$deliveryModule = ModuleQuery::create()->findPk($deliveryId);
|
} else {
|
||||||
|
$this->pageNotFound();
|
||||||
if ($deliveryModule) {
|
|
||||||
$request->getSession()->setDelivery($deliveryId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,9 @@ class Delivery extends BaseSpecificModule
|
|||||||
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
|
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
|
||||||
|
|
||||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
$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 = $moduleReflection->newInstance();
|
||||||
|
|
||||||
$moduleInstance->setRequest($this->request);
|
$moduleInstance->setRequest($this->request);
|
||||||
|
|||||||
@@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{loop type="delivery" name="delivery.list"}
|
{loop type="delivery" name="delivery.list"}
|
||||||
<li>id : #ID</li>
|
<li>
|
||||||
<li>prix : #PRICE</li>
|
<ul>
|
||||||
|
<li>id : {#ID}</li>
|
||||||
|
<li>prix : {#PRICE}</li>
|
||||||
|
<li>Choisir : <a href="{url path="/delivery/choose/{#ID}"}">Choisir</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
{/loop}
|
{/loop}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user