diff --git a/core/lib/Thelia/Command/Skeleton/Module/Class.php b/core/lib/Thelia/Command/Skeleton/Module/Class.php
index c9c7109ac..c4c90aa60 100755
--- a/core/lib/Thelia/Command/Skeleton/Module/Class.php
+++ b/core/lib/Thelia/Command/Skeleton/Module/Class.php
@@ -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
diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml
index f8b156946..4c88f707f 100755
--- a/core/lib/Thelia/Config/Resources/routing/front.xml
+++ b/core/lib/Thelia/Config/Resources/routing/front.xml
@@ -60,4 +60,10 @@
cart
+
+
+ Thelia\Controller\Front\DeliveryController::select
+
+
+
diff --git a/core/lib/Thelia/Controller/Front/DeliveryController.php b/core/lib/Thelia/Controller/Front/DeliveryController.php
new file mode 100644
index 000000000..abb2e7fae
--- /dev/null
+++ b/core/lib/Thelia/Controller/Front/DeliveryController.php
@@ -0,0 +1,55 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Controller\Front;
+use Thelia\Model\ModuleQuery;
+use Thelia\Tools\URL;
+
+
+/**
+ * Class DeliveryController
+ * @package Thelia\Controller\Front
+ * @author Manuel Raynaud
+ */
+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);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php
index 4a486e488..8c6a241ec 100755
--- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php
+++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php
@@ -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");
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php
index 89725e33b..145da3c02 100755
--- a/core/lib/Thelia/Module/BaseModule.php
+++ b/core/lib/Thelia/Module/BaseModule.php
@@ -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();
diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php
new file mode 100644
index 000000000..d3a70c9c4
--- /dev/null
+++ b/local/modules/Colissimo/Colissimo.php
@@ -0,0 +1,82 @@
+. */
+/* */
+/*************************************************************************************/
+
+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.
+ }
+
+}
diff --git a/local/modules/Colissimo/Config/config.xml b/local/modules/Colissimo/Config/config.xml
new file mode 100644
index 000000000..2430f5027
--- /dev/null
+++ b/local/modules/Colissimo/Config/config.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/local/modules/Colissimo/Config/plugin.xml b/local/modules/Colissimo/Config/plugin.xml
new file mode 100644
index 000000000..e69de29bb
diff --git a/local/modules/Colissimo/Config/schema.xml b/local/modules/Colissimo/Config/schema.xml
new file mode 100644
index 000000000..a4e2315b0
--- /dev/null
+++ b/local/modules/Colissimo/Config/schema.xml
@@ -0,0 +1,7 @@
+
+
+
+
+