Merge branch 'frontend' of github.com:thelia/thelia into frontend
This commit is contained in:
@@ -56,7 +56,7 @@ class HttpException extends BaseAction implements EventSubscriberInterface
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template thant shoud be used
|
||||
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate()->getPath());
|
||||
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate());
|
||||
|
||||
//$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView());
|
||||
|
||||
|
||||
@@ -279,12 +279,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
|
||||
|
||||
/* call pay method */
|
||||
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
$paymentModuleInstance = $paymentModuleReflection->newInstance();
|
||||
|
||||
$paymentModuleInstance->setRequest($this->getRequest());
|
||||
$paymentModuleInstance->setDispatcher($this->getDispatcher());
|
||||
|
||||
$paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
||||
$paymentModuleInstance->pay($placedOrder);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
<form name="thelia.front.contact" class="Thelia\Form\ContactForm"/>
|
||||
<form name="thelia.front.newsletter" class="Thelia\Form\NewsletterForm"/>
|
||||
|
||||
<!-- Forms for Admin -->
|
||||
<form name="thelia.install.step3" class="Thelia\Form\InstallStep3Form"/>
|
||||
|
||||
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
|
||||
|
||||
<form name="thelia.admin.customer.create" class="Thelia\Form\CustomerCreateForm"/>
|
||||
|
||||
@@ -56,16 +56,6 @@
|
||||
<tag name="router.register" priority="0"/>
|
||||
</service>
|
||||
|
||||
<service id="router.front" class="%router.class%">
|
||||
<argument type="service" id="router.xmlLoader"/>
|
||||
<argument>front.xml</argument>
|
||||
<argument type="collection">
|
||||
<argument key="cache_dir">%kernel.cache_dir%</argument>
|
||||
<argument key="debug">%kernel.debug%</argument>
|
||||
</argument>
|
||||
<argument type="service" id="request.context"/>
|
||||
<tag name="router.register" priority="128"/>
|
||||
</service>
|
||||
|
||||
<service id="router.rewrite" class="Thelia\Core\Routing\RewritingRouter">
|
||||
<tag name="router.register" priority="255"/>
|
||||
|
||||
@@ -934,15 +934,23 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.module.toggle-activation" path="/admin/modules/toggle-activation/{module_id}">
|
||||
<route id="admin.module.toggle-activation" path="/admin/module/toggle-activation/{module_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::toggleActivationAction</default>
|
||||
<requirement key="module_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.module.delete" path="/admin/modules/delete">
|
||||
<route id="admin.module.delete" path="/admin/module/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<!--
|
||||
Generic module route.
|
||||
Will be use if module route is not define in module own config file.
|
||||
-->
|
||||
<route id="admin.module.configure" path="/admin/module/{module_code}">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::configureAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end Modules rule management -->
|
||||
|
||||
<!-- tax management -->
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="ajax.mini-cart" path="/ajax/mini-cart">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">includes/mini-cart</default>
|
||||
</route>
|
||||
<route id="ajax.addCartMessage" path="/ajax/addCartMessage">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">includes/addedToCart</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- Register -->
|
||||
<route id="customer.create.process" path="/register" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
|
||||
<default key="_view">register</default>
|
||||
</route>
|
||||
|
||||
<!-- Login -->
|
||||
<route id="customer.login.process" path="/login" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::loginAction</default>
|
||||
<default key="_view">login</default>
|
||||
</route>
|
||||
|
||||
<!-- Forgot Password -->
|
||||
<route id="customer.password.retrieve.process" path="/password" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::newPasswordAction</default>
|
||||
<default key="_view">password</default>
|
||||
</route>
|
||||
|
||||
<!-- Logout -->
|
||||
<route id="customer.logout.process" path="/logout">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Account -->
|
||||
<route id="customer.update.view" path="/account/update" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::viewAction</default>
|
||||
<default key="_view">account-update</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.update.process" path="/account/update" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::updateAction</default>
|
||||
<default key="_view">account-update</default>
|
||||
</route>
|
||||
|
||||
|
||||
<route id="customer.password.change.process" path="/account/password" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::updatePasswordAction</default>
|
||||
<default key="_view">account-password</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.password.change.view" path="/account/password" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">account-password</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.order.pdf.delivery" path="/account/order/pdf/delivery/{order_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::generateDeliveryPdf</default>
|
||||
<requirement key="order_id">\d+</requirement>
|
||||
</route>
|
||||
<!-- end customer routes -->
|
||||
|
||||
<!-- customer address routes -->
|
||||
<route id="address.create.view" path="/address/create" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">address</default>
|
||||
</route>
|
||||
|
||||
<route id="address.create" path="/address/create" methods="post" >
|
||||
<default key="_controller">Thelia\Controller\Front\AddressController::createAction</default>
|
||||
<default key="_view">address</default>
|
||||
</route>
|
||||
|
||||
<route id="address.edit" path="/address/update/{address_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\AddressController::updateViewAction</default>
|
||||
<default key="_view">address-update</default>
|
||||
</route>
|
||||
|
||||
<route id="address.update" path="/address/update/{address_id}" methods="post" >
|
||||
<default key="_controller">Thelia\Controller\Front\AddressController::processUpdateAction</default>
|
||||
<default key="_view">address-update</default>
|
||||
</route>
|
||||
|
||||
<route id="address.delete" path="/address/delete/{address_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\AddressController::deleteAction</default>
|
||||
<default key="_view">account</default>
|
||||
</route>
|
||||
|
||||
<route id="address.generateModal" path="/address/modal/{address_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\AddressController::generateModalAction</default>
|
||||
<default key="_view">modal-address</default>
|
||||
<requirement key="address_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end customer address routes -->
|
||||
|
||||
<!-- cart routes -->
|
||||
<route id="cart.view" path="/cart">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.add.process" path="/cart/add">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::addItem</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.delete.process" path="/cart/delete/{cart_item}">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::deleteItem</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.update.quantity" path="/cart/update">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::changeItem</default>
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::changeItem</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
<!-- end cart routes -->
|
||||
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.process" path="/order/delivery" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::deliver</default>
|
||||
<default key="_view">order-delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="order.delivery" path="/order/delivery">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">order-delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice.process" path="/order/invoice" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::invoice</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice" path="/order/invoice">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.coupon.process" path="/order/coupon" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CouponController::consumeAction</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.payment.process" path="/order/pay">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
</route>
|
||||
|
||||
<route id="order.placed" path="/order/placed/{order_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::orderPlaced</default>
|
||||
<default key="_view">order-placed</default>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
<!-- contact management -->
|
||||
<route id="contact.send" path="/contact" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\ContactController::sendAction</default>
|
||||
<default key="_view">contact</default>
|
||||
</route>
|
||||
|
||||
<route id="contact.success" path="/contact/success">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">contact-success</default>
|
||||
</route>
|
||||
<!-- end contact management -->
|
||||
|
||||
<!-- newsletter management -->
|
||||
<route id="newsletter.process" path="/newsletter" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\NewsletterController::subscribeAction</default>
|
||||
<default key="_view">newsletter</default>
|
||||
</route>
|
||||
<!-- end newsletter management -->
|
||||
|
||||
<!-- Default Route -->
|
||||
<route id="default" path="/{_view}">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">index</default>
|
||||
<requirement key="_view">^(?!admin)[^/]+</requirement>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<!-- The assets manager -->
|
||||
<service id="assetic.asset.manager" class="Thelia\Core\Template\Assets\AsseticAssetManager" >
|
||||
<argument>%kernel.environment%</argument>
|
||||
<argument>%kernel.debug%</argument>
|
||||
</service>
|
||||
|
||||
<!-- Smarty parser plugins -->
|
||||
|
||||
@@ -201,7 +201,7 @@ class BaseAdminController extends BaseController
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template that should be used
|
||||
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveAdminTemplate()->getPath());
|
||||
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveAdminTemplate());
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
@@ -188,6 +188,24 @@ class ModuleController extends AbstractCrudController
|
||||
return $this->render("modules");
|
||||
}
|
||||
|
||||
public function configureAction($module_code)
|
||||
{
|
||||
$module = ModuleQuery::create()->findOneByCode($module_code);
|
||||
|
||||
if(null === $module) {
|
||||
throw new \InvalidArgumentException(sprintf("Module `%s` does not exists", $module_code));
|
||||
}
|
||||
|
||||
if (null !== $response = $this->checkAuth(array(), $module_code, AccessManager::VIEW)) return $response;
|
||||
|
||||
return $this->render(
|
||||
"module-configure",
|
||||
array(
|
||||
"module_code" => $module_code,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function toggleActivationAction($module_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, array(), AccessManager::UPDATE)) return $response;
|
||||
|
||||
@@ -45,10 +45,6 @@ class TranslationsController extends BaseAdminController
|
||||
// Find modules
|
||||
$modules = ModuleQuery::create()->joinI18n($this->getCurrentEditionLocale())->orderByPosition()->find();
|
||||
|
||||
TemplateHelper::getInstance()->getList(TemplateDefinition::BACK_OFFICE);
|
||||
TemplateHelper::getInstance()->getList(TemplateDefinition::PDF);
|
||||
TemplateHelper::getInstance()->getList(TemplateDefinition::FRONT_OFFICE);
|
||||
|
||||
// Get related strings, if all input data are here
|
||||
$item_to_translate = $this->getRequest()->get('item_to_translate');
|
||||
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
<?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\Core\Event\Address\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Address\AddressEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\AddressCreateForm;
|
||||
use Thelia\Form\AddressUpdateForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
/**
|
||||
* Class AddressController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AddressController extends BaseFrontController
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller for generate modal containing update form
|
||||
* Check if request is a XmlHttpRequest and address owner is the current customer
|
||||
* @param $address_id
|
||||
*/
|
||||
public function generateModalAction($address_id)
|
||||
{
|
||||
|
||||
$this->checkAuth();
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create controller.
|
||||
* Check if customer is logged in
|
||||
*
|
||||
* Dispatch TheliaEvents::ADDRESS_CREATE event
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
|
||||
$this->checkAuth();
|
||||
|
||||
$addressCreate = new AddressCreateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($addressCreate, "post");
|
||||
$event = $this->createAddressEvent($form);
|
||||
$event->setCustomer($customer);
|
||||
|
||||
$this->dispatch(TheliaEvents::ADDRESS_CREATE, $event);
|
||||
$this->redirectSuccess($addressCreate);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error during address creation process : %s", $message));
|
||||
|
||||
$addressCreate->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($addressCreate)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateViewAction($address_id)
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (!$address || $customer->getId() != $address->getCustomerId()) {
|
||||
$this->redirectToRoute('default');
|
||||
}
|
||||
|
||||
$this->getParserContext()->set("address_id", $address_id);
|
||||
}
|
||||
|
||||
public function processUpdateAction($address_id)
|
||||
{
|
||||
$this->checkAuth();
|
||||
$request = $this->getRequest();
|
||||
|
||||
$addressUpdate = new AddressUpdateForm($request);
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($addressUpdate);
|
||||
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (null === $address) {
|
||||
$this->redirectToRoute('default');
|
||||
}
|
||||
|
||||
if ($address->getCustomer()->getId() != $customer->getId()) {
|
||||
$this->redirectToRoute('default');
|
||||
}
|
||||
|
||||
$event = $this->createAddressEvent($form);
|
||||
$event->setAddress($address);
|
||||
|
||||
$this->dispatch(TheliaEvents::ADDRESS_UPDATE, $event);
|
||||
|
||||
$this->redirectSuccess($addressUpdate);
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
$this->getParserContext()->set("address_id", $address_id);
|
||||
if ($message !== false) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("Error during address creation process : %s", $message));
|
||||
|
||||
$addressUpdate->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($addressUpdate)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAction($address_id)
|
||||
{
|
||||
$this->checkAuth();
|
||||
$error_message = false;
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$address = AddressQuery::create()->findPk($address_id);
|
||||
|
||||
if (!$address || $customer->getId() != $address->getCustomerId()) {
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
return $this->jsonResponse(json_encode(array(
|
||||
"success" => false,
|
||||
"message" => "Error during address deletion process"
|
||||
)));
|
||||
} else {
|
||||
$this->redirectToRoute('default');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::ADDRESS_DELETE, new AddressEvent($address));
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf('Error during address deletion : %s', $error_message));
|
||||
|
||||
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
if ($error_message) {
|
||||
$response = $this->jsonResponse(json_encode(array(
|
||||
"success" => false,
|
||||
"message" => $error_message
|
||||
)));
|
||||
} else {
|
||||
$response = $this->jsonResponse(json_encode(array(
|
||||
"success" => true,
|
||||
"message" => ""
|
||||
)));;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
} else {
|
||||
$this->redirectToRoute('default', array('view'=>'account'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function createAddressEvent($form)
|
||||
{
|
||||
return new AddressCreateOrUpdateEvent(
|
||||
$form->get("label")->getData(),
|
||||
$form->get("title")->getData(),
|
||||
$form->get("firstname")->getData(),
|
||||
$form->get("lastname")->getData(),
|
||||
$form->get("address1")->getData(),
|
||||
$form->get("address2")->getData(),
|
||||
$form->get("address3")->getData(),
|
||||
$form->get("zipcode")->getData(),
|
||||
$form->get("city")->getData(),
|
||||
$form->get("country")->getData(),
|
||||
$form->get("cellphone")->getData(),
|
||||
$form->get("phone")->getData(),
|
||||
$form->get("company")->getData(),
|
||||
$form->get("is_default")->getData()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class BaseFrontController extends BaseController
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template that should be used
|
||||
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveFrontTemplate()->getPath());
|
||||
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveFrontTemplate());
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
<?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 Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Core\Event\Cart\CartEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Form\CartAdd;
|
||||
|
||||
class CartController extends BaseFrontController
|
||||
{
|
||||
use \Thelia\Cart\CartTrait;
|
||||
|
||||
public function addItem()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$cartAdd = $this->getAddCartForm($request);
|
||||
$message = null;
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($cartAdd);
|
||||
|
||||
$cartEvent = $this->getCartEvent();
|
||||
$cartEvent->setNewness($form->get("newness")->getData());
|
||||
$cartEvent->setAppend($form->get("append")->getData());
|
||||
$cartEvent->setQuantity($form->get("quantity")->getData());
|
||||
$cartEvent->setProductSaleElementsId($form->get("product_sale_elements_id")->getData());
|
||||
$cartEvent->setProduct($form->get("product")->getData());
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_ADDITEM, $cartEvent);
|
||||
|
||||
$this->redirectSuccess();
|
||||
|
||||
} catch (PropelException $e) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("Failed to add item to cart with message : %s", $e->getMessage()));
|
||||
$message = "Failed to add this article to your cart, please try again";
|
||||
} catch (FormValidationException $e) {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
$request = $this->getRequest();
|
||||
$request->attributes->set('_view', "includes/mini-cart");
|
||||
}
|
||||
|
||||
if ($message) {
|
||||
$cartAdd->setErrorMessage($message);
|
||||
$this->getParserContext()->addForm($cartAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public function changeItem()
|
||||
{
|
||||
$cartEvent = $this->getCartEvent();
|
||||
$cartEvent->setCartItem($this->getRequest()->get("cart_item"));
|
||||
$cartEvent->setQuantity($this->getRequest()->get("quantity"));
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
|
||||
|
||||
$this->redirectSuccess();
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function deleteItem()
|
||||
{
|
||||
$cartEvent = $this->getCartEvent();
|
||||
$cartEvent->setCartItem($this->getRequest()->get("cart_item"));
|
||||
|
||||
try {
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_DELETEITEM, $cartEvent);
|
||||
|
||||
$this->redirectSuccess();
|
||||
} catch (PropelException $e) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during deleting cartItem with message : %s", $e->getMessage()));
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* use Thelia\Cart\CartTrait for searching current cart or create a new one
|
||||
*
|
||||
* @return \Thelia\Core\Event\Cart\CartEvent
|
||||
*/
|
||||
protected function getCartEvent()
|
||||
{
|
||||
$cart = $this->getCart($this->getRequest());
|
||||
|
||||
return new CartEvent($cart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the good way to construct the cart form
|
||||
*
|
||||
* @param Request $request
|
||||
* @return CartAdd
|
||||
*/
|
||||
private function getAddCartForm(Request $request)
|
||||
{
|
||||
if ($request->isMethod("post")) {
|
||||
$cartAdd = new CartAdd($request);
|
||||
} else {
|
||||
$cartAdd = new CartAdd(
|
||||
$request,
|
||||
"form",
|
||||
array(),
|
||||
array(
|
||||
'csrf_protection' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $cartAdd;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<?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\Form\ContactForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* Class ContactController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContactController extends BaseFrontController
|
||||
{
|
||||
/**
|
||||
* send contact message
|
||||
*/
|
||||
public function sendAction()
|
||||
{
|
||||
$error_message = false;
|
||||
$contactForm = new ContactForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($contactForm);
|
||||
|
||||
$message = \Swift_Message::newInstance($form->get('subject')->getData())
|
||||
->addFrom($form->get('email')->getData(), $form->get('name')->getData())
|
||||
->addTo(ConfigQuery::read('contact_email'), ConfigQuery::read('company_name'))
|
||||
->setBody($form->get('message')->getData())
|
||||
;
|
||||
|
||||
$this->getMailer()->send($message);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
if ($error_message !== false) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message));
|
||||
|
||||
$contactForm->setErrorMessage($error_message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($contactForm)
|
||||
->setGeneralError($error_message)
|
||||
;
|
||||
} else {
|
||||
$this->redirectToRoute('contact.success');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?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 Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
||||
use Thelia\Form\CouponCode;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Order;
|
||||
|
||||
/**
|
||||
* Class CouponController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*/
|
||||
class CouponController extends BaseFrontController
|
||||
{
|
||||
|
||||
/**
|
||||
* Test Coupon consuming
|
||||
*/
|
||||
public function consumeAction()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
$message = false;
|
||||
$couponCodeForm = new CouponCode($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($couponCodeForm, 'post');
|
||||
|
||||
$couponCode = $form->get('coupon-code')->getData();
|
||||
|
||||
if (null === $couponCode || empty($couponCode)) {
|
||||
$message = true;
|
||||
throw new \Exception('Coupon code can\'t be empty');
|
||||
}
|
||||
|
||||
$couponConsumeEvent = new CouponConsumeEvent($couponCode);
|
||||
|
||||
// Dispatch Event to the Action
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::COUPON_CONSUME, $couponConsumeEvent);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf('Please check your coupon code: %s', $e->getMessage());
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf('Sorry, an error occurred: %s', $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$couponCodeForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($couponCodeForm)
|
||||
->setGeneralError($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,388 +0,0 @@
|
||||
<?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\Core\Event\Customer\CustomerCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerLoginEvent;
|
||||
use Thelia\Core\Event\LostPasswordEvent;
|
||||
use Thelia\Core\Event\Newsletter\NewsletterEvent;
|
||||
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Core\Security\Exception\UsernameNotFoundException;
|
||||
use Thelia\Form\CustomerCreateForm;
|
||||
use Thelia\Form\CustomerLogin;
|
||||
use Thelia\Form\CustomerLostPasswordForm;
|
||||
use Thelia\Form\CustomerPasswordUpdateForm;
|
||||
use Thelia\Form\CustomerProfileUpdateForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\NewsletterQuery;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Core\Security\Exception\WrongPasswordException;
|
||||
|
||||
/**
|
||||
* Class CustomerController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class CustomerController extends BaseFrontController
|
||||
{
|
||||
use \Thelia\Cart\CartTrait;
|
||||
|
||||
public function newPasswordAction()
|
||||
{
|
||||
if (! $this->getSecurityContext()->hasCustomerUser()) {
|
||||
$message = false;
|
||||
|
||||
$passwordLost = new CustomerLostPasswordForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
$form = $this->validateForm($passwordLost);
|
||||
|
||||
$event = new LostPasswordEvent($form->get("email")->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::LOST_PASSWORD, $event);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer creation process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$passwordLost->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($passwordLost)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new customer.
|
||||
* On success, redirect to success_url if exists, otherwise, display the same view again.
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
if (! $this->getSecurityContext()->hasCustomerUser()) {
|
||||
|
||||
$message = false;
|
||||
|
||||
$customerCreation = new CustomerCreateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($customerCreation, "post");
|
||||
|
||||
$customerCreateEvent = $this->createEventInstance($form->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent);
|
||||
|
||||
$newCustomer = $customerCreateEvent->getCustomer();
|
||||
|
||||
// Newsletter
|
||||
if (true === $form->get('newsletter')->getData()) {
|
||||
$newsletterEmail = $newCustomer->getEmail();
|
||||
$nlEvent = new NewsletterEvent($newsletterEmail, $this->getRequest()->getSession()->getLang()->getLocale());
|
||||
$nlEvent->setFirstname($newCustomer->getFirstname());
|
||||
$nlEvent->setLastname($newCustomer->getLastname());
|
||||
|
||||
// Security : Check if this new Email address already exist
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterEmail)) {
|
||||
$nlEvent->setId($newsletter->getId());
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent);
|
||||
} else {
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent);
|
||||
}
|
||||
}
|
||||
|
||||
$this->processLogin($customerCreateEvent->getCustomer());
|
||||
|
||||
$cart = $this->getCart($this->getRequest());
|
||||
if ($cart->getCartItems()->count() > 0) {
|
||||
$this->redirectToRoute('cart.view');
|
||||
} else {
|
||||
$this->redirectSuccess($customerCreation);
|
||||
}
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer creation process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$customerCreation->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerCreation)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update customer data. On success, redirect to success_url if exists.
|
||||
* Otherwise, display the same view again.
|
||||
*/
|
||||
public function viewAction()
|
||||
{
|
||||
$this->checkAuth();
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$data = array(
|
||||
'id' => $customer->getId(),
|
||||
'title' => $customer->getTitleId(),
|
||||
'firstname' => $customer->getFirstName(),
|
||||
'lastname' => $customer->getLastName(),
|
||||
'email' => $customer->getEmail(),
|
||||
'newsletter' => null !== NewsletterQuery::create()->findOneByEmail($customer->getEmail()),
|
||||
);
|
||||
|
||||
$customerProfileUpdateForm = new CustomerProfileUpdateForm($this->getRequest(), 'form', $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($customerProfileUpdateForm);
|
||||
}
|
||||
|
||||
public function updatePasswordAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
$message = false;
|
||||
|
||||
$customerPasswordUpdateForm = new CustomerPasswordUpdateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($customerPasswordUpdateForm, "post");
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFILE, $customerChangeEvent);
|
||||
|
||||
$this->redirectSuccess($customerPasswordUpdateForm);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer password modification process : %s.", $message));
|
||||
|
||||
$customerPasswordUpdateForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerPasswordUpdateForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
|
||||
$message = false;
|
||||
|
||||
$customerProfileUpdateForm = new CustomerProfileUpdateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$newsletterOldEmail = $customer->getEmail();
|
||||
|
||||
$form = $this->validateForm($customerProfileUpdateForm, "post");
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_UPDATEPROFILE, $customerChangeEvent);
|
||||
|
||||
$updatedCustomer = $customerChangeEvent->getCustomer();
|
||||
|
||||
// Newsletter
|
||||
if (true === $form->get('newsletter')->getData()) {
|
||||
$nlEvent = new NewsletterEvent($updatedCustomer->getEmail(), $this->getRequest()->getSession()->getLang()->getLocale());
|
||||
$nlEvent->setFirstname($updatedCustomer->getFirstname());
|
||||
$nlEvent->setLastname($updatedCustomer->getLastname());
|
||||
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterOldEmail)) {
|
||||
$nlEvent->setId($newsletter->getId());
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent);
|
||||
} else {
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent);
|
||||
}
|
||||
} else {
|
||||
if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterOldEmail)) {
|
||||
$nlEvent = new NewsletterEvent($updatedCustomer->getEmail(), $this->getRequest()->getSession()->getLang()->getLocale());
|
||||
$nlEvent->setId($newsletter->getId());
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_UNSUBSCRIBE, $nlEvent);
|
||||
}
|
||||
}
|
||||
|
||||
$this->processLogin($updatedCustomer);
|
||||
|
||||
$this->redirectSuccess($customerProfileUpdateForm);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer modification process : %s.", $message));
|
||||
|
||||
$customerProfileUpdateForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerProfileUpdateForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform user login. On a successful login, the user is redirected to the URL
|
||||
* found in the success_url form parameter, or / if none was found.
|
||||
*
|
||||
* If login is not successfull, the same view is displayed again.
|
||||
*
|
||||
*/
|
||||
public function loginAction()
|
||||
{
|
||||
if (! $this->getSecurityContext()->hasCustomerUser()) {
|
||||
$message = false;
|
||||
|
||||
$request = $this->getRequest();
|
||||
$customerLoginForm = new CustomerLogin($request);
|
||||
|
||||
try {
|
||||
|
||||
$form = $this->validateForm($customerLoginForm, "post");
|
||||
|
||||
// If User is a new customer
|
||||
if ($form->get('account')->getData() == 0 && !$form->get("email")->getErrors()) {
|
||||
$this->redirectToRoute("customer.create.process", array("email" => $form->get("email")->getData()));
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
||||
$authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);
|
||||
|
||||
$customer = $authenticator->getAuthentifiedUser();
|
||||
|
||||
$this->processLogin($customer);
|
||||
|
||||
$this->redirectSuccess($customerLoginForm);
|
||||
|
||||
} catch (UsernameNotFoundException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
} catch (WrongPasswordException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
} catch (AuthenticationException $e) {
|
||||
$message = "Wrong email or password. Please try again";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer login process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$customerLoginForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()->addForm($customerLoginForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform customer logout.
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_LOGOUT);
|
||||
}
|
||||
|
||||
// Redirect to home page
|
||||
$this->redirect(URL::getInstance()->getIndexPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch event for customer login action
|
||||
*
|
||||
* @param Customer $customer
|
||||
*/
|
||||
protected function processLogin(Customer $customer)
|
||||
{
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return \Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent
|
||||
*/
|
||||
private function createEventInstance($data)
|
||||
{
|
||||
$customerCreateEvent = new CustomerCreateOrUpdateEvent(
|
||||
isset($data["title"])?$data["title"]:null,
|
||||
isset($data["firstname"])?$data["firstname"]:null,
|
||||
isset($data["lastname"])?$data["lastname"]:null,
|
||||
isset($data["address1"])?$data["address1"]:null,
|
||||
isset($data["address2"])?$data["address2"]:null,
|
||||
isset($data["address3"])?$data["address3"]:null,
|
||||
isset($data["phone"])?$data["phone"]:null,
|
||||
isset($data["cellphone"])?$data["cellphone"]:null,
|
||||
isset($data["zipcode"])?$data["zipcode"]:null,
|
||||
isset($data["city"])?$data["city"]:null,
|
||||
isset($data["country"])?$data["country"]:null,
|
||||
isset($data["email"])?$data["email"]:null,
|
||||
isset($data["password"]) ? $data["password"]:null,
|
||||
$this->getRequest()->getSession()->getLang()->getId(),
|
||||
isset($data["reseller"])?$data["reseller"]:null,
|
||||
isset($data["sponsor"])?$data["sponsor"]:null,
|
||||
isset($data["discount"])?$data["discount"]:null,
|
||||
isset($data["company"])?$data["company"]:null
|
||||
);
|
||||
|
||||
return $customerCreateEvent;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?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\Core\Event\Newsletter\NewsletterEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\NewsletterForm;
|
||||
|
||||
/**
|
||||
* Class NewsletterController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class NewsletterController extends BaseFrontController
|
||||
{
|
||||
|
||||
public function subscribeAction()
|
||||
{
|
||||
$error_message = false;
|
||||
$newsletterForm = new NewsletterForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
$form = $this->validateForm($newsletterForm);
|
||||
|
||||
$event = new NewsletterEvent(
|
||||
$form->get('email')->getData(),
|
||||
$this->getRequest()->getSession()->getLang()->getLocale()
|
||||
);
|
||||
|
||||
if (null !== $customer = $this->getSecurityContext()->getCustomerUser()) {
|
||||
$event->setFirstname($customer->getFirstname());
|
||||
$event->setLastname($customer->getLastname());
|
||||
}
|
||||
|
||||
$this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $event);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf('Error during newsletter subscription : %s', $error_message));
|
||||
|
||||
// If Ajax Request
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
if ($error_message) {
|
||||
$response = $this->jsonResponse(json_encode(array(
|
||||
"success" => false,
|
||||
"message" => $error_message
|
||||
)));
|
||||
} else {
|
||||
$response = $this->jsonResponse(json_encode(array(
|
||||
"success" => true,
|
||||
"message" => "Thanks for signing up! We'll keep you posted whenever we have any new updates."
|
||||
)));;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
} else {
|
||||
$newsletterForm->setErrorMessage($error_message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($newsletterForm)
|
||||
->setGeneralError($error_message)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
<?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 Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Core\Event\PdfEvent;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Form\OrderDelivery;
|
||||
use Thelia\Form\OrderPayment;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery;
|
||||
use Thelia\Model\Base\OrderQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class OrderController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderController extends BaseFrontController
|
||||
{
|
||||
/**
|
||||
* set delivery address
|
||||
* set delivery module
|
||||
*/
|
||||
public function deliver()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
$message = false;
|
||||
|
||||
$orderDelivery = new OrderDelivery($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($orderDelivery, "post");
|
||||
|
||||
$deliveryAddressId = $form->get("delivery-address")->getData();
|
||||
$deliveryModuleId = $form->get("delivery-module")->getData();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
|
||||
$deliveryModule = ModuleQuery::create()->findPk($deliveryModuleId);
|
||||
|
||||
/* check that the delivery address belongs to the current customer */
|
||||
if ($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception("Delivery address does not belong to the current customer");
|
||||
}
|
||||
|
||||
/* check that the delivery module fetches the delivery address area */
|
||||
if(AreaDeliveryModuleQuery::create()
|
||||
->filterByAreaId($deliveryAddress->getCountry()->getAreaId())
|
||||
->filterByDeliveryModuleId($deliveryModuleId)
|
||||
->count() == 0) {
|
||||
throw new \Exception("Delivery module cannot be use with selected delivery address");
|
||||
}
|
||||
|
||||
/* get postage amount */
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
$postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setDeliveryAddress($deliveryAddressId);
|
||||
$orderEvent->setDeliveryModule($deliveryModuleId);
|
||||
$orderEvent->setPostage($postage);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
|
||||
|
||||
$this->redirectToRoute("order.invoice");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$orderDelivery->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($orderDelivery)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set invoice address
|
||||
* set payment module
|
||||
*/
|
||||
public function invoice()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
$this->checkValidDelivery();
|
||||
|
||||
$message = false;
|
||||
|
||||
$orderPayment = new OrderPayment($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($orderPayment, "post");
|
||||
|
||||
$invoiceAddressId = $form->get("invoice-address")->getData();
|
||||
$paymentModuleId = $form->get("payment-module")->getData();
|
||||
|
||||
/* check that the invoice address belongs to the current customer */
|
||||
$invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId);
|
||||
if ($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception("Invoice address does not belong to the current customer");
|
||||
}
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setInvoiceAddress($invoiceAddressId);
|
||||
$orderEvent->setPaymentModule($paymentModuleId);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_INVOICE_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_PAYMENT_MODULE, $orderEvent);
|
||||
|
||||
$this->redirectToRoute("order.payment.process");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (PropelException $e) {
|
||||
$this->getParserContext()->setGeneralError($e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during order payment process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$orderPayment->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($orderPayment)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function pay()
|
||||
{
|
||||
/* check customer */
|
||||
$this->checkAuth();
|
||||
|
||||
/* check cart count */
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
/* check delivery address and module */
|
||||
$this->checkValidDelivery();
|
||||
|
||||
/* check invoice address and payment module */
|
||||
$this->checkValidInvoice();
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent);
|
||||
|
||||
$placedOrder = $orderEvent->getPlacedOrder();
|
||||
|
||||
if (null !== $placedOrder && null !== $placedOrder->getId()) {
|
||||
/* order has been placed */
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId()))));
|
||||
} else {
|
||||
/* order has not been placed */
|
||||
$this->redirectToRoute('cart.view');
|
||||
}
|
||||
}
|
||||
|
||||
public function orderPlaced($order_id)
|
||||
{
|
||||
/* check if the placed order matched the customer */
|
||||
$placedOrder = OrderQuery::create()->findPk(
|
||||
$this->getRequest()->attributes->get('order_id')
|
||||
);
|
||||
|
||||
if (null === $placedOrder) {
|
||||
throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder);
|
||||
}
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
if (null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) {
|
||||
throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder);
|
||||
}
|
||||
|
||||
$this->getParserContext()->set("placed_order_id", $placedOrder->getId());
|
||||
}
|
||||
|
||||
protected function getOrderEvent()
|
||||
{
|
||||
$order = $this->getOrder($this->getRequest());
|
||||
|
||||
return new OrderEvent($order);
|
||||
}
|
||||
|
||||
public function getOrder(Request $request)
|
||||
{
|
||||
$session = $request->getSession();
|
||||
|
||||
if (null !== $order = $session->getOrder()) {
|
||||
return $order;
|
||||
}
|
||||
|
||||
$order = new Order();
|
||||
|
||||
$session->setOrder($order);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
public function generateInvoicePdf($order_id)
|
||||
{
|
||||
/* check customer */
|
||||
$this->checkAuth();
|
||||
return $this->generateOrderPdf($order_id, ConfigQuery::read('pdf_invoice_file', 'invoice'));
|
||||
}
|
||||
|
||||
public function generateDeliveryPdf($order_id)
|
||||
{
|
||||
/* check customer */
|
||||
$this->checkAuth();
|
||||
return $this->generateOrderPdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class ViewListener implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
$parser = $this->container->get('thelia.parser');
|
||||
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate()->getPath());
|
||||
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate());
|
||||
$request = $this->container->get('request');
|
||||
|
||||
try {
|
||||
|
||||
@@ -40,13 +40,13 @@ use Symfony\Component\Filesystem\Exception\IOException;
|
||||
*/
|
||||
class AsseticAssetManager implements AssetManagerInterface
|
||||
{
|
||||
protected $developmentMode;
|
||||
protected $debugMode;
|
||||
|
||||
protected $source_file_extensions = array('less', 'js', 'coffee', 'html', 'tpl', 'htm', 'xml');
|
||||
|
||||
public function __construct($developmentMode)
|
||||
public function __construct($debugMode)
|
||||
{
|
||||
$this->developmentMode = $developmentMode;
|
||||
$this->debugMode = $debugMode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
*/
|
||||
protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
|
||||
{
|
||||
Tlog::getInstance()->addDebug("Copying assets from ", $from_directory, " to ", $to_directory);
|
||||
Tlog::getInstance()->addDebug("Copying assets from $from_directory to $to_directory");
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
@@ -333,10 +333,10 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
// This is the final name of the generated asset
|
||||
$asset_destination_path = $output_directory . DS . $asset_target_filename;
|
||||
|
||||
Tlog::getInstance()->addDebug("Asset destination name: ", $asset_destination_path);
|
||||
Tlog::getInstance()->addDebug("Asset destination full path: $asset_destination_path");
|
||||
|
||||
// We generate an asset only if it does not exists, or if the asset processing is forced in development mode
|
||||
if (! file_exists($asset_destination_path) || ($this->developmentMode && ConfigQuery::read('process_assets', true)) ) {
|
||||
if (! file_exists($asset_destination_path) || ($this->debugMode && ConfigQuery::read('process_assets', true)) ) {
|
||||
|
||||
$writer = new AssetWriter($output_directory);
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ namespace Thelia\Core\Template\Loop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Module\DeliveryModuleInterface;
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
@@ -63,14 +65,24 @@ class Delivery extends BaseSpecificModule
|
||||
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {
|
||||
$loopResultRow = new LoopResultRow($deliveryModule);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||
|
||||
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
|
||||
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->setRequest($this->request);
|
||||
$moduleInstance->setDispatcher($this->dispatcher);
|
||||
try {
|
||||
$postage = $moduleInstance->getPostage($country);
|
||||
} catch(OrderException $e) {
|
||||
switch($e->getCode()) {
|
||||
case OrderException::DELIVERY_MODULE_UNAVAILABLE:
|
||||
/* do not show this delivery module */
|
||||
continue(2);
|
||||
break;
|
||||
default:
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $deliveryModule->getId())
|
||||
@@ -78,7 +90,7 @@ class Delivery extends BaseSpecificModule
|
||||
->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO'))
|
||||
->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set('POSTAGE', $moduleInstance->getPostage($country))
|
||||
->set('POSTAGE', $postage)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
@@ -148,6 +149,29 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
$hasConfigurationInterface = false;
|
||||
|
||||
/* first test if module defines it's own config route */
|
||||
$routerId = "router." . $module->getBaseDir();
|
||||
if($this->container->has($routerId)) {
|
||||
try {
|
||||
if($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) {
|
||||
$hasConfigurationInterface = true;
|
||||
}
|
||||
} catch(ResourceNotFoundException $e) {
|
||||
/* $hasConfigurationInterface stays false */
|
||||
}
|
||||
}
|
||||
|
||||
/* if not ; test if it uses admin inclusion : module_configuration.html */
|
||||
if(false === $hasConfigurationInterface) {
|
||||
if(file_exists( sprintf("%s/%s/AdminIncludes/%s.html", THELIA_MODULE_DIR, $module->getBaseDir(), "module_configuration"))) {
|
||||
$hasConfigurationInterface = true;
|
||||
}
|
||||
}
|
||||
|
||||
$loopResultRow->set("CONFIGURABLE", $hasConfigurationInterface ? 1 : 0);
|
||||
|
||||
if (null !== $this->getProfile()) {
|
||||
$accessValue = $module->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
@@ -26,6 +26,7 @@ use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Module\PaymentModuleInterface;
|
||||
|
||||
/**
|
||||
* Class Payment
|
||||
@@ -47,14 +48,11 @@ class Payment extends BaseSpecificModule implements PropelSearchLoopInterface
|
||||
foreach ($loopResult->getResultDataCollection() as $paymentModule) {
|
||||
$loopResultRow = new LoopResultRow($paymentModule);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
||||
|
||||
if (false === $moduleInstance instanceof PaymentModuleInterface) {
|
||||
throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->setRequest($this->request);
|
||||
$moduleInstance->setDispatcher($this->dispatcher);
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $paymentModule->getId())
|
||||
|
||||
@@ -44,10 +44,16 @@ class Module extends AbstractSmartyPlugin
|
||||
|
||||
if (false !== $location = $this->getParam($params, 'location', false)) {
|
||||
|
||||
$moduleLimit = $this->getParam($params, 'module', null);
|
||||
|
||||
$modules = ModuleQuery::getActivated();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
|
||||
if(null !== $moduleLimit && $moduleLimit != $module->getCode()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file = sprintf("%s/%s/AdminIncludes/%s.html", THELIA_MODULE_DIR, $module->getBaseDir(), $location);
|
||||
|
||||
if (file_exists($file)) {
|
||||
|
||||
@@ -13,6 +13,7 @@ use Thelia\Core\Template\ParserInterface;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Exception\ResourceNotFoundException;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
|
||||
@@ -23,13 +24,15 @@ use Thelia\Core\Template\TemplateHelper;
|
||||
*/
|
||||
class SmartyParser extends Smarty implements ParserInterface
|
||||
{
|
||||
|
||||
public $plugins = array();
|
||||
|
||||
protected $request;
|
||||
protected $dispatcher;
|
||||
protected $parserContext;
|
||||
|
||||
protected $backOfficeTemplateDirectories = array();
|
||||
protected $frontOfficeTemplateDirectories = array();
|
||||
|
||||
protected $template = "";
|
||||
|
||||
protected $status = 200;
|
||||
@@ -101,15 +104,59 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function setTemplate($template_path_from_template_base)
|
||||
public function addBackOfficeTemplateDirectory($templateName, $templateDirectory, $key)
|
||||
{
|
||||
$this->template = $template_path_from_template_base;
|
||||
$this->backOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
|
||||
$this->addTemplateDir(THELIA_TEMPLATE_DIR.$this->template, 0);
|
||||
public function addFrontOfficeTemplateDirectory($templateName, $templateDirectory, $key)
|
||||
{
|
||||
$this->frontOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
|
||||
}
|
||||
|
||||
$config_dir = THELIA_TEMPLATE_DIR.$this->template.'/configs';
|
||||
/**
|
||||
* @param TemplateDefinition $templateDefinition
|
||||
*/
|
||||
public function setTemplate(TemplateDefinition $templateDefinition)
|
||||
{
|
||||
$this->template = $templateDefinition->getPath();
|
||||
|
||||
$this->setConfigDir($config_dir);
|
||||
/* init template directories */
|
||||
$this->setTemplateDir(array());
|
||||
|
||||
/* add main template directory */
|
||||
$this->addTemplateDir(THELIA_TEMPLATE_DIR . $this->template, 0);
|
||||
|
||||
/* define config directory */
|
||||
$configDirectory = THELIA_TEMPLATE_DIR . $this->template . '/configs';
|
||||
$this->setConfigDir($configDirectory);
|
||||
|
||||
/* add modules template directories */
|
||||
switch($templateDefinition->getType()) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
/* do not pass array directly to addTemplateDir since we cant control on keys */
|
||||
if(isset($this->frontOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
foreach($this->frontOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::BACK_OFFICE:
|
||||
/* do not pass array directly to addTemplateDir since we cant control on keys */
|
||||
if(isset($this->backOfficeTemplateDirectories[$templateDefinition->getName()])) {
|
||||
foreach($this->backOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
|
||||
$this->addTemplateDir($directory, $key);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TemplateDefinition::PDF:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTemplate()
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
class TemplateDefinition
|
||||
{
|
||||
@@ -30,7 +29,8 @@ class TemplateDefinition
|
||||
const BACK_OFFICE = 2;
|
||||
const PDF = 3;
|
||||
|
||||
const BACK_OFFICE_SUBDIR = 'admin/';
|
||||
const FRONT_OFFICE_SUBDIR = 'frontOffice/';
|
||||
const BACK_OFFICE_SUBDIR = 'backOffice/';
|
||||
const PDF_SUBDIR = 'pdf/';
|
||||
|
||||
/**
|
||||
@@ -54,12 +54,20 @@ class TemplateDefinition
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
|
||||
if ($type == self::BACK_OFFICE)
|
||||
$this->path = self::BACK_OFFICE_SUBDIR . $name;
|
||||
else if ($type == self::PDF)
|
||||
$this->path = self::PDF_SUBDIR . $name;
|
||||
else
|
||||
$this->path = $name;
|
||||
switch($type) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
$this->path = self::FRONT_OFFICE_SUBDIR . $name;
|
||||
break;
|
||||
case TemplateDefinition::BACK_OFFICE:
|
||||
$this->path = self::BACK_OFFICE_SUBDIR . $name;
|
||||
break;
|
||||
case TemplateDefinition::PDF:
|
||||
$this->path = self::PDF_SUBDIR . $name;
|
||||
break;
|
||||
default:
|
||||
$this->path = $name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
@@ -46,6 +46,9 @@ class TemplateHelper
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActivePdfTemplate() {
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-pdf-template', 'default'),
|
||||
@@ -53,6 +56,9 @@ class TemplateHelper
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActiveAdminTemplate() {
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-admin-template', 'default'),
|
||||
@@ -60,6 +66,9 @@ class TemplateHelper
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateDefinition
|
||||
*/
|
||||
public function getActiveFrontTemplate() {
|
||||
return new TemplateDefinition(
|
||||
ConfigQuery::read('active-front-template', 'default'),
|
||||
@@ -78,7 +87,7 @@ class TemplateHelper
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::PDF_SUBDIR;
|
||||
}
|
||||
else {
|
||||
$baseDir = THELIA_TEMPLATE_DIR;
|
||||
$baseDir = THELIA_TEMPLATE_DIR.TemplateDefinition::FRONT_OFFICE_SUBDIR;
|
||||
|
||||
$exclude = array(TemplateDefinition::BACK_OFFICE_SUBDIR, TemplateDefinition::PDF_SUBDIR);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Thelia\Core;
|
||||
use Propel\Runtime\Connection\ConnectionWrapper;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
@@ -45,6 +46,7 @@ use Thelia\Core\Bundle;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Config\DatabaseConfiguration;
|
||||
use Thelia\Config\DefinePropel;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
use Thelia\Core\TheliaContainerBuilder;
|
||||
use Thelia\Core\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
@@ -126,7 +128,6 @@ class Thelia extends Kernel
|
||||
$modules = \Thelia\Model\ModuleQuery::getActivated();
|
||||
|
||||
$translationDirs = array();
|
||||
$templateDirs = array();
|
||||
$parser = $container->getDefinition('thelia.parser');
|
||||
foreach ($modules as $module) {
|
||||
|
||||
@@ -134,7 +135,7 @@ class Thelia extends Kernel
|
||||
|
||||
$defintion = new Definition();
|
||||
$defintion->setClass($module->getFullNamespace());
|
||||
$defintion->addMethodCall("setContainer", array('service_container'));
|
||||
$defintion->addMethodCall("setContainer", array(new Reference('service_container')));
|
||||
|
||||
$container->setDefinition(
|
||||
"module.".$module->getCode(),
|
||||
@@ -151,9 +152,54 @@ class Thelia extends Kernel
|
||||
$translationDirs[] = $dir;
|
||||
}
|
||||
|
||||
if (is_dir($dir = THELIA_MODULE_DIR . "/" . $code . "/templates")) {
|
||||
//$templateDirs[$code] = $dir;
|
||||
$parser->addMethodCall('addTemplateDir', array($dir, $code));
|
||||
/* is there a front-office template directory ? */
|
||||
$frontOfficeModuleTemplateDirectory = sprintf("%s%s%stemplates%s%s", THELIA_MODULE_DIR, $code, DS, DS, TemplateDefinition::FRONT_OFFICE_SUBDIR);
|
||||
if (is_dir($frontOfficeModuleTemplateDirectory)) {
|
||||
try {
|
||||
$moduleFrontOfficeTemplateBrowser = new \DirectoryIterator($frontOfficeModuleTemplateDirectory);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
/* browse the directory */
|
||||
foreach ($moduleFrontOfficeTemplateBrowser as $moduleFrontOfficeTemplateContent) {
|
||||
/* is it a directory which is not . or .. ? */
|
||||
if ($moduleFrontOfficeTemplateContent->isDir() && !$moduleFrontOfficeTemplateContent->isDot()) {
|
||||
$parser->addMethodCall(
|
||||
'addFrontOfficeTemplateDirectory',
|
||||
array(
|
||||
$moduleFrontOfficeTemplateContent->getFilename(),
|
||||
$moduleFrontOfficeTemplateContent->getPathName(),
|
||||
$code,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* is there a back-office template directory ? */
|
||||
$backOfficeModuleTemplateDirectory = sprintf("%s%s%stemplates%s%s", THELIA_MODULE_DIR, $code, DS, DS, TemplateDefinition::BACK_OFFICE_SUBDIR);
|
||||
if (is_dir($backOfficeModuleTemplateDirectory)) {
|
||||
try {
|
||||
$moduleBackOfficeTemplateBrowser = new \DirectoryIterator($backOfficeModuleTemplateDirectory);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
/* browse the directory */
|
||||
foreach ($moduleBackOfficeTemplateBrowser as $moduleBackOfficeTemplateContent) {
|
||||
/* is it a directory which is not . or .. ? */
|
||||
if ($moduleBackOfficeTemplateContent->isDir() && !$moduleBackOfficeTemplateContent->isDot()) {
|
||||
$parser->addMethodCall(
|
||||
'addBackOfficeTemplateDirectory',
|
||||
array(
|
||||
$moduleBackOfficeTemplateContent->getFilename(),
|
||||
$moduleBackOfficeTemplateContent->getPathName(),
|
||||
$code,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// TODO: process module configuration exception
|
||||
|
||||
@@ -38,6 +38,7 @@ class OrderException extends \RuntimeException
|
||||
const CART_EMPTY = 100;
|
||||
|
||||
const UNDEFINED_DELIVERY = 200;
|
||||
const DELIVERY_MODULE_UNAVAILABLE = 201;
|
||||
|
||||
public function __construct($message, $code = null, $arguments = array(), $previous = null)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,14 @@ class CheckPermission extends BaseInstall
|
||||
'upload_max_filesize' => 2097152
|
||||
);
|
||||
|
||||
protected $extensions = array(
|
||||
'curl',
|
||||
'gd',
|
||||
'intl',
|
||||
'mcrypt',
|
||||
'pdo_mysql',
|
||||
);
|
||||
|
||||
protected $validationMessages = array();
|
||||
|
||||
/** @var bool If permissions are OK */
|
||||
@@ -103,6 +111,14 @@ class CheckPermission extends BaseInstall
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($this->extensions as $extension) {
|
||||
$this->validationMessages[$extension] = array(
|
||||
'text' => '',
|
||||
'hint' => $this->getI18nExtensionHint(),
|
||||
'status' => true,
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($verifyInstall);
|
||||
}
|
||||
|
||||
@@ -139,6 +155,15 @@ class CheckPermission extends BaseInstall
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->extensions as $extension) {
|
||||
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, true);
|
||||
if (false === extension_loaded($extension)) {
|
||||
$this->isValid = false;
|
||||
$this->validationMessages[$extension]['status'] = false;
|
||||
$this->validationMessages[$extension]['text'] = $this->getI18nExtensionText($extension, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -176,7 +201,6 @@ class CheckPermission extends BaseInstall
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get Translated text about the directory state
|
||||
*
|
||||
@@ -198,8 +222,7 @@ class CheckPermission extends BaseInstall
|
||||
$sentence,
|
||||
array(
|
||||
'%directory%' => $directory
|
||||
),
|
||||
'install-wizard'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$translatedText = sprintf('Your directory %s needs to be writable', $directory);
|
||||
@@ -208,6 +231,19 @@ class CheckPermission extends BaseInstall
|
||||
return $translatedText;
|
||||
}
|
||||
|
||||
protected function getI18nExtensionText($extension, $isValid)
|
||||
{
|
||||
if ($isValid) {
|
||||
$sentence = '%extension% php extension is loaded';
|
||||
} else {
|
||||
$sentence = '%extension% php extension is not loaded';
|
||||
}
|
||||
|
||||
return $this->translator->trans($sentence, array(
|
||||
'%extension%' => $extension
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Translated hint about the directory state
|
||||
*
|
||||
@@ -266,6 +302,11 @@ class CheckPermission extends BaseInstall
|
||||
return $translatedText;
|
||||
}
|
||||
|
||||
protected function getI18nExtensionHint()
|
||||
{
|
||||
return $this->translator->trans('This extension must be installed and loaded');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Translated hint about the config requirement issue
|
||||
*
|
||||
@@ -275,9 +316,7 @@ class CheckPermission extends BaseInstall
|
||||
{
|
||||
$sentence = 'Modifying this value on your server php.ini file with admin rights could help';
|
||||
$translatedText = $this->translator->trans(
|
||||
$sentence,
|
||||
array(),
|
||||
'install-wizard'
|
||||
$sentence
|
||||
);
|
||||
|
||||
return $translatedText;
|
||||
@@ -306,8 +345,7 @@ class CheckPermission extends BaseInstall
|
||||
array(
|
||||
'%expectedValue%' => $expectedValue,
|
||||
'%currentValue%' => $currentValue,
|
||||
),
|
||||
'install-wizard'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$translatedText = sprintf('Thelia needs at least PHP %s (%s currently)', $expectedValue, $currentValue);
|
||||
@@ -326,8 +364,7 @@ class CheckPermission extends BaseInstall
|
||||
$sentence = 'Upgrading your version of PHP with admin rights could help';
|
||||
$translatedText = $this->translator->trans(
|
||||
$sentence,
|
||||
array(),
|
||||
'install-wizard'
|
||||
array()
|
||||
);
|
||||
|
||||
return $translatedText;
|
||||
|
||||
@@ -112,4 +112,18 @@ class Cart extends BaseCart
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getWeight()
|
||||
{
|
||||
$weight = 0;
|
||||
|
||||
foreach($this->getCartItems() as $cartItem) {
|
||||
$itemWeight = $cartItem->getProductSaleElements()->getWeight();
|
||||
$itemWeight *= $cartItem->getQuantity();
|
||||
|
||||
$weight += $itemWeight;
|
||||
}
|
||||
|
||||
return $weight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Tests\Action;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Thelia\Core\Event\Order\OrderAddressEvent;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
@@ -250,6 +251,10 @@ class OrderTest extends \PHPUnit_Framework_TestCase
|
||||
throw new \Exception('No Payment Module fixture found');
|
||||
}
|
||||
|
||||
/* define payment module in container */
|
||||
$paymentModuleClass = $paymentModule->getFullNamespace();
|
||||
$this->container->set(sprintf('module.%s', $paymentModule->getCode()), new $paymentModuleClass());
|
||||
|
||||
$this->orderEvent->getOrder()->chosenDeliveryAddress = $validDeliveryAddress->getId();
|
||||
$this->orderEvent->getOrder()->chosenInvoiceAddress = $validInvoiceAddress->getId();
|
||||
$this->orderEvent->getOrder()->setDeliveryModuleId($deliveryModule->getId());
|
||||
|
||||
@@ -61,7 +61,11 @@ class CategoryTest extends BaseLoopTestor
|
||||
$category->save();
|
||||
}
|
||||
|
||||
$this->baseTestSearchById($category->getId());
|
||||
$otherParameters = array(
|
||||
"visible" => "*",
|
||||
);
|
||||
|
||||
$this->baseTestSearchById($category->getId(), $otherParameters);
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
|
||||
@@ -61,7 +61,11 @@ class ContentTest extends BaseLoopTestor
|
||||
$content->save();
|
||||
}
|
||||
|
||||
$this->baseTestSearchById($content->getId());
|
||||
$otherParameters = array(
|
||||
"visible" => "*",
|
||||
);
|
||||
|
||||
$this->baseTestSearchById($content->getId(), $otherParameters);
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
|
||||
@@ -61,7 +61,11 @@ class FolderTest extends BaseLoopTestor
|
||||
$folder->save();
|
||||
}
|
||||
|
||||
$this->baseTestSearchById($folder->getId());
|
||||
$otherParameters = array(
|
||||
"visible" => "*",
|
||||
);
|
||||
|
||||
$this->baseTestSearchById($folder->getId(), $otherParameters);
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
|
||||
@@ -62,7 +62,11 @@ class ProductTest extends BaseLoopTestor
|
||||
$product->save();
|
||||
}
|
||||
|
||||
$this->baseTestSearchById($product->getId());
|
||||
$otherParameters = array(
|
||||
"visible" => "*",
|
||||
);
|
||||
|
||||
$this->baseTestSearchById($product->getId(), $otherParameters);
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
|
||||
Reference in New Issue
Block a user