set good module delivery id in session

This commit is contained in:
Manuel Raynaud
2013-09-06 16:12:57 +02:00
parent 1686d6d87c
commit 2dee65727d
9 changed files with 218 additions and 1 deletions

View File

@@ -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

View File

@@ -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>

View 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);
}
}
}
}

View File

@@ -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");
}
}

View File

@@ -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();