set good module delivery id in session
This commit is contained in:
@@ -25,7 +25,7 @@ namespace %%NAMESPACE%%;
|
|||||||
|
|
||||||
use Thelia\Module\BaseModule;
|
use Thelia\Module\BaseModule;
|
||||||
|
|
||||||
class Class extends BaseModule
|
class %%CLASSNAME%% extends BaseModule
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
|
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
|
||||||
|
|||||||
@@ -60,4 +60,10 @@
|
|||||||
<default key="_view">cart</default>
|
<default key="_view">cart</default>
|
||||||
</route>
|
</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>
|
</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
|
* assign cart id in session
|
||||||
*
|
*
|
||||||
* @param $cart_id
|
* @param $cart_id
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCart($cart_id)
|
public function setCart($cart_id)
|
||||||
{
|
{
|
||||||
$this->set("thelia.cart_id", $cart_id);
|
$this->set("thelia.cart_id", $cart_id);
|
||||||
return $this;
|
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 install();
|
||||||
abstract public function destroy();
|
abstract public function destroy();
|
||||||
|
|
||||||
|
|||||||
82
local/modules/Colissimo/Colissimo.php
Normal file
82
local/modules/Colissimo/Colissimo.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?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 Colissimo;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Thelia\Module\BaseModule;
|
||||||
|
use Thelia\Module\DeliveryModuleInterface;
|
||||||
|
|
||||||
|
class Colissimo extends BaseModule implements DeliveryModuleInterface
|
||||||
|
{
|
||||||
|
protected $request;
|
||||||
|
protected $dispatcher;
|
||||||
|
|
||||||
|
public function setRequest(Request $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRequest()
|
||||||
|
{
|
||||||
|
return $this->request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDispatcher(EventDispatcherInterface $dispatcher)
|
||||||
|
{
|
||||||
|
$this->dispatcher = $dispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDispatcher()
|
||||||
|
{
|
||||||
|
return $this->dispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* calculate and return delivery price
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function calculate()
|
||||||
|
{
|
||||||
|
// TODO: Implement calculate() method.
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
|
||||||
|
* Like install and destroy
|
||||||
|
*/
|
||||||
|
public function install()
|
||||||
|
{
|
||||||
|
// TODO: Implement install() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy()
|
||||||
|
{
|
||||||
|
// TODO: Implement destroy() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
36
local/modules/Colissimo/Config/config.xml
Normal file
36
local/modules/Colissimo/Config/config.xml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<config xmlns="http://thelia.net/schema/dic/config"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||||
|
|
||||||
|
<loops>
|
||||||
|
<!-- sample definition
|
||||||
|
<loop name="MySuperLoop" class="MyModule\Loop\MySuperLoop" />
|
||||||
|
-->
|
||||||
|
</loops>
|
||||||
|
|
||||||
|
<forms>
|
||||||
|
<!--
|
||||||
|
<form name="MyFormName" class="MyModule\Form\MySuperForm" />
|
||||||
|
-->
|
||||||
|
</forms>
|
||||||
|
|
||||||
|
<commands>
|
||||||
|
<!--
|
||||||
|
<command class="MyModule\Command\MySuperCommand" />
|
||||||
|
-->
|
||||||
|
</commands>
|
||||||
|
|
||||||
|
<templateDirectives>
|
||||||
|
<!-- Sample definition
|
||||||
|
<templateDirectives class="MyModule\Directive\MyTemplateDirective" name="my_filter"/>
|
||||||
|
-->
|
||||||
|
</templateDirectives>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<services>
|
||||||
|
|
||||||
|
</services>
|
||||||
|
-->
|
||||||
|
</config>
|
||||||
0
local/modules/Colissimo/Config/plugin.xml
Normal file
0
local/modules/Colissimo/Config/plugin.xml
Normal file
7
local/modules/Colissimo/Config/schema.xml
Normal file
7
local/modules/Colissimo/Config/schema.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<database defaultIdMethod="native" name="thelia" namespace="Colissimo\Model">
|
||||||
|
<!--
|
||||||
|
See propel documentation on http://propelorm.org for all information about schema file
|
||||||
|
-->
|
||||||
|
<external-schema filename="/home/manu/dev/www/thelia/local/config/schema.xml" referenceOnly="true" />
|
||||||
|
</database>
|
||||||
Reference in New Issue
Block a user