set good module delivery id in session
This commit is contained in:
@@ -25,7 +25,7 @@ namespace %%NAMESPACE%%;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class Class extends BaseModule
|
||||
class %%CLASSNAME%% extends BaseModule
|
||||
{
|
||||
/**
|
||||
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
|
||||
|
||||
@@ -60,4 +60,10 @@
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
</routes>
|
||||
|
||||
55
core/lib/Thelia/Controller/Front/DeliveryController.php
Normal file
55
core/lib/Thelia/Controller/Front/DeliveryController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Front;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
|
||||
/**
|
||||
* Class DeliveryController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class DeliveryController extends BaseFrontController
|
||||
{
|
||||
public function select()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirect(URL::getInstance()->getIndexPage());
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$deliveryId = $request->query->get("delivery_id");
|
||||
|
||||
if($deliveryId)
|
||||
{
|
||||
$deliveryModule = ModuleQuery::create()->findPk($deliveryId);
|
||||
|
||||
if ($deliveryModule) {
|
||||
$request->getSession()->setDelivery($deliveryId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,10 +164,28 @@ class Session extends BaseSession
|
||||
* assign cart id in session
|
||||
*
|
||||
* @param $cart_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setCart($cart_id)
|
||||
{
|
||||
$this->set("thelia.cart_id", $cart_id);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* assign delivery id in session
|
||||
*
|
||||
* @param $delivery_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setDelivery($delivery_id)
|
||||
{
|
||||
$this->set("thelia.delivery_id", $delivery_id);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelivery()
|
||||
{
|
||||
return $this->get("thelia.delivery_id");
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,19 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
}
|
||||
|
||||
public function hasContainer()
|
||||
{
|
||||
return null === $this->container;
|
||||
}
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
if($this->hasContainer() === false) {
|
||||
throw new \RuntimeException("Sorry, container his not available in this context");
|
||||
}
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
abstract public function install();
|
||||
abstract public function destroy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user