Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (22) and others # Via Manuel Raynaud (7) and others * 'master' of https://github.com/thelia/thelia: (32 commits) refactor name for updating actions choose UPDATE word for name actions add update address action and create tests 404 not found management Working Fix unset namespace modify travis script test rewriting exception Fixed minor bug in Currencies Finished currency edition Added route methods address action implementation hot fix rewriting add address create controller and event Added AdminUtilities Smarty plugin, optimized templates update customer model createOrUpdate method update address model fix redirect process in viewListener refactor reset_install script refactor install process, database management in dedicated class ... Conflicts: local/config/schema.xml reset_install.sh
This commit is contained in:
@@ -150,12 +150,33 @@ class BaseAdminController extends BaseController
|
||||
return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the route path defined for the givent route ID
|
||||
*
|
||||
* @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml
|
||||
*
|
||||
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
|
||||
*/
|
||||
protected function getRoute($routeId) {
|
||||
return $this->getRouteFromRouter('router.admin', $routeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to à route ID related URL
|
||||
*
|
||||
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
|
||||
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
|
||||
*/
|
||||
public function redirectToRoute($routeId, $urlParameters = array()) {
|
||||
$this->redirect(URL::absoluteUrl($this->getRoute($routeId), $urlParameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current edition lang ID, checking if a change was requested in the current request
|
||||
*/
|
||||
protected function getCurrentEditionLangId() {
|
||||
return $this->getRequest()->get(
|
||||
'edition_language',
|
||||
'edit_language_id',
|
||||
$this->getSession()->getAdminEditionLangId()
|
||||
);
|
||||
}
|
||||
@@ -196,29 +217,32 @@ class BaseAdminController extends BaseController
|
||||
|
||||
$session = $this->getSession();
|
||||
|
||||
// Find the current edit language ID
|
||||
$edition_language = $this->getCurrentEditionLangId();
|
||||
|
||||
// Current back-office (not edition) language
|
||||
$current_lang = LangQuery::create()->findOneById($session->getLangId());
|
||||
$current_lang = LangQuery::create()->findOneById($session->getLangId());
|
||||
|
||||
// Find the current edit language ID
|
||||
$edition_language = LangQuery::create()->findOneById($this->getCurrentEditionLangId());
|
||||
|
||||
// Prepare common template variables
|
||||
$args = array_merge($args, array(
|
||||
'locale' => $session->getLocale(),
|
||||
'lang_code' => $session->getLang(),
|
||||
'lang_id' => $session->getLangId(),
|
||||
'locale' => $session->getLocale(),
|
||||
'lang_code' => $session->getLang(),
|
||||
'lang_id' => $session->getLangId(),
|
||||
|
||||
'datetime_format' => $current_lang->getDateTimeFormat(),
|
||||
'date_format' => $current_lang->getDateFormat(),
|
||||
'time_format' => $current_lang->getTimeFormat(),
|
||||
'datetime_format' => $current_lang->getDateTimeFormat(),
|
||||
'date_format' => $current_lang->getDateFormat(),
|
||||
'time_format' => $current_lang->getTimeFormat(),
|
||||
|
||||
'edition_language' => $edition_language,
|
||||
'edit_language_id' => $edition_language->getId(),
|
||||
'edit_language_locale' => $edition_language->getLocale(),
|
||||
|
||||
'current_url' => htmlspecialchars($this->getRequest()->getUri())
|
||||
'current_url' => htmlspecialchars($this->getRequest()->getUri())
|
||||
));
|
||||
|
||||
// Update the current edition language in session
|
||||
$this->getSession()->setAdminEditionLangId($edition_language);
|
||||
$this->getSession()->setAdminEditionLangId($edition_language->getId());
|
||||
|
||||
// Render the template.
|
||||
try {
|
||||
|
||||
@@ -188,7 +188,7 @@ class CategoryController extends BaseAdminController
|
||||
|
||||
// Find the current order
|
||||
$category_order = $this->getRequest()->get(
|
||||
'category_order',
|
||||
'order',
|
||||
$this->getSession()->get('admin.category_order', 'manual')
|
||||
);
|
||||
|
||||
|
||||
@@ -42,6 +42,25 @@ use Thelia\Form\ConfigCreationForm;
|
||||
*/
|
||||
class ConfigController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* Render the currencies list, ensuring the sort order is set.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
protected function renderList() {
|
||||
|
||||
// Find the current order
|
||||
$order = $this->getRequest()->get(
|
||||
'order',
|
||||
$this->getSession()->get('admin.variables_order', 'name')
|
||||
);
|
||||
|
||||
// Store the current sort order in session
|
||||
$this->getSession()->set('admin.variables_order', $order);
|
||||
|
||||
return $this->render('variables', array('order' => $order));
|
||||
}
|
||||
|
||||
/**
|
||||
* The default action is displaying the variables list.
|
||||
*
|
||||
@@ -51,7 +70,7 @@ class ConfigController extends BaseAdminController
|
||||
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.variables.view")) return $response;
|
||||
|
||||
return $this->render('variables');
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +143,7 @@ class ConfigController extends BaseAdminController
|
||||
}
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->render('variables');
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +229,7 @@ class ConfigController extends BaseAdminController
|
||||
->setPostscriptum($data['postscriptum'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CONFIG_MODIFY, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::CONFIG_UPDATE, $changeEvent);
|
||||
|
||||
// Log config modification
|
||||
$changedObject = $changeEvent->getConfig();
|
||||
@@ -220,10 +239,11 @@ class ConfigController extends BaseAdminController
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirect(URL::absoluteUrl(
|
||||
"admin/configuration/variables/change",
|
||||
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.variables.change",
|
||||
array('variable_id' => $variable_id)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
@@ -276,7 +296,7 @@ class ConfigController extends BaseAdminController
|
||||
$this->dispatch(TheliaEvents::CONFIG_SETVALUE, $event);
|
||||
}
|
||||
|
||||
$this->redirect(URL::adminViewUrl('variables'));
|
||||
$this->redirectToRoute('admin.configuration.variables.default');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,6 +314,6 @@ class ConfigController extends BaseAdminController
|
||||
|
||||
$this->dispatch(TheliaEvents::CONFIG_DELETE, $event);
|
||||
|
||||
$this->redirect(URL::adminViewUrl('variables'));
|
||||
$this->redirectToRoute('admin.configuration.variables.default');
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class CurrencyController extends BaseAdminController
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.create")) return $response;
|
||||
|
||||
$currency = false;
|
||||
$error_msg = false;
|
||||
|
||||
// Create the Creation Form
|
||||
$creationForm = new CurrencyCreationForm($this->getRequest());
|
||||
@@ -101,7 +101,9 @@ class CurrencyController extends BaseAdminController
|
||||
->setCurrencyName($data['name'])
|
||||
->setLocale($data["locale"])
|
||||
->setSymbol($data['symbol'])
|
||||
;
|
||||
->setCode($data['code'])
|
||||
->setRate($data['rate'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CURRENCY_CREATE, $createEvent);
|
||||
|
||||
@@ -118,24 +120,24 @@ class CurrencyController extends BaseAdminController
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$currency = sprintf("Please check your input: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Please check your input: %s", $ex->getMessage());
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$currency = sprintf("Sorry, an error occured: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Sorry, an error occured: %s", $ex->getMessage());
|
||||
}
|
||||
|
||||
if ($currency !== false) {
|
||||
if ($error_msg !== false) {
|
||||
// An error has been detected: log it
|
||||
Tlog::getInstance()->error(sprintf("Error during currency creation process : %s. Exception was %s", $currency, $ex->getCurrency()));
|
||||
Tlog::getInstance()->error(sprintf("Error during currency creation process : %s. Exception was %s", $error_msg, $ex->getMessage()));
|
||||
|
||||
// Mark the form as errored
|
||||
$creationForm->setErrorCurrency($currency);
|
||||
$creationForm->setErrorMessage($error_msg);
|
||||
|
||||
// Pass it to the parser, along with the error currency
|
||||
$this->getParserContext()
|
||||
->addForm($creationForm)
|
||||
->setGeneralError($currency)
|
||||
->setGeneralError($error_msg)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ class CurrencyController extends BaseAdminController
|
||||
'locale' => $currency->getLocale(),
|
||||
'code' => $currency->getCode(),
|
||||
'symbol' => $currency->getSymbol(),
|
||||
'rate' => $currency->getSubject()
|
||||
'rate' => $currency->getRate()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
@@ -191,7 +193,7 @@ class CurrencyController extends BaseAdminController
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
|
||||
|
||||
$currency = false;
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new CurrencyModificationForm($this->getRequest());
|
||||
@@ -218,7 +220,7 @@ class CurrencyController extends BaseAdminController
|
||||
->setRate($data['rate'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CURRENCY_MODIFY, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::CURRENCY_UPDATE, $changeEvent);
|
||||
|
||||
// Log currency modification
|
||||
$changedObject = $changeEvent->getCurrency();
|
||||
@@ -228,10 +230,10 @@ class CurrencyController extends BaseAdminController
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirect(URL::absoluteUrl(
|
||||
"admin/configuration/currencies/change",
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.currencies.change",
|
||||
array('currency_id' => $currency_id)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
@@ -239,24 +241,24 @@ class CurrencyController extends BaseAdminController
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Invalid data entered
|
||||
$currency = sprintf("Please check your input: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Please check your input: %s", $ex->getMessage());
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$currency = sprintf("Sorry, an error occured: %s", $ex->getCurrency());
|
||||
$error_msg = sprintf("Sorry, an error occured: %s", $ex->getMessage());
|
||||
}
|
||||
|
||||
if ($currency !== false) {
|
||||
if ($error_msg !== false) {
|
||||
// Log error currency
|
||||
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $currency, $ex->getCurrency()));
|
||||
Tlog::getInstance()->error(sprintf("Error during currency modification process : %s. Exception was %s", $error_msg, $ex->getMessage()));
|
||||
|
||||
// Mark the form as errored
|
||||
$changeForm->setErrorCurrency($currency);
|
||||
$changeForm->setErrorMessage($error_msg);
|
||||
|
||||
// Pas the form and the error to the parser
|
||||
$this->getParserContext()
|
||||
->addForm($changeForm)
|
||||
->setGeneralError($currency)
|
||||
->setGeneralError($error_msg)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -264,6 +266,47 @@ class CurrencyController extends BaseAdminController
|
||||
return $this->render('currency-edit', array('currency_id' => $currency_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default currency
|
||||
*/
|
||||
public function setDefaultAction() {
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
|
||||
|
||||
$changeEvent = new CurrencyChangeEvent($this->getRequest()->get('currency_id', 0));
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent->setIsDefault(true);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CURRENCY_SET_DEFAULT, $changeEvent);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage(sprintf("Sorry, an error occured: %s", $ex->getMessage()));
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.configuration.currencies.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update currencies rates
|
||||
*/
|
||||
public function updateRatesAction() {
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.currencies.change")) return $response;
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage(sprintf("Sorry, an error occured: %s", $ex->getMessage()));
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.configuration.currencies.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a currency object
|
||||
*
|
||||
@@ -279,6 +322,6 @@ class CurrencyController extends BaseAdminController
|
||||
|
||||
$this->dispatch(TheliaEvents::CURRENCY_DELETE, $event);
|
||||
|
||||
$this->redirect(URL::adminViewUrl('currencies'));
|
||||
$this->redirectToRoute('admin.configuration.currencies.default');
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ class MessageController extends BaseAdminController
|
||||
->setTextMessage($data['text_message'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::MESSAGE_MODIFY, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::MESSAGE_UPDATE, $changeEvent);
|
||||
|
||||
// Log message modification
|
||||
$changedObject = $changeEvent->getMessage();
|
||||
@@ -214,10 +214,10 @@ class MessageController extends BaseAdminController
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirect(URL::absoluteUrl(
|
||||
"admin/configuration/messages/change",
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.messages.change",
|
||||
array('message_id' => $message_id)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
|
||||
@@ -46,7 +46,7 @@ class SessionController extends BaseAdminController
|
||||
$this->getSecurityContext()->clearAdminUser();
|
||||
|
||||
// Go back to login page.
|
||||
return Redirect::exec(URL::absoluteUrl('/admin/login')); // FIXME - should be a parameter
|
||||
$this->redirectToRoute('admin.login');
|
||||
}
|
||||
|
||||
public function checkLoginAction()
|
||||
|
||||
@@ -31,11 +31,12 @@ use Thelia\Tools\Redirect;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Thelia\Core\Factory\ActionEventFactory;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Core\Event\DefaultActionEvent;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -177,9 +178,9 @@ class BaseController extends ContainerAware
|
||||
*
|
||||
* @param string $url
|
||||
*/
|
||||
public function redirect($url)
|
||||
public function redirect($url, $status = 302)
|
||||
{
|
||||
Redirect::exec($url);
|
||||
Redirect::exec($url, $status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,4 +201,32 @@ class BaseController extends ContainerAware
|
||||
|
||||
if (null !== $url) $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a route path from the route id.
|
||||
*
|
||||
* @param $routerName
|
||||
* @param $routeId
|
||||
*
|
||||
* @return mixed
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function getRouteFromRouter($routerName, $routeId) {
|
||||
$route = $this->container->get($routerName)->getRouteCollection()->get($routeId);
|
||||
|
||||
if ($route == null) {
|
||||
throw new InvalidArgumentException(sprintf("Route ID '%s' does not exists.", $routeId));
|
||||
}
|
||||
|
||||
return $route->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 404 error
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
protected function pageNotFound()
|
||||
{
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
}
|
||||
@@ -26,4 +26,24 @@ use Thelia\Controller\BaseController;
|
||||
|
||||
class BaseFrontController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Return the route path defined for the givent route ID
|
||||
*
|
||||
* @param string $routeId a route ID, as defines in Config/Resources/routing/front.xml
|
||||
*
|
||||
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
|
||||
*/
|
||||
protected function getRoute($routeId) {
|
||||
return $this->getRouteFromRouter('router.front', $routeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to à route ID related URL
|
||||
*
|
||||
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
|
||||
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
|
||||
*/
|
||||
public function redirectToRoute($routeId, $urlParameters = array()) {
|
||||
$this->redirect(URL::absoluteUrl($this->getRoute($routeId), $urlParameters));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class CartController extends BaseFrontController
|
||||
$cartEvent->setQuantity($this->getRequest()->get("quantity"));
|
||||
|
||||
try {
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_CHANGEITEM, $cartEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
|
||||
|
||||
$this->redirectSuccess();
|
||||
} catch(PropelException $e) {
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?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\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\AddressForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\Customer;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
|
||||
/**
|
||||
* Class CustomerAddressController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class CustomerAddressController extends BaseFrontController
|
||||
{
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirect(URL::getIndexPage());
|
||||
}
|
||||
|
||||
$addressCreate = new AddressForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($addressCreate, "post");
|
||||
$event = $this->createAddressEvent($form->getData(), $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)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
protected function createAddressEvent($data, Customer $customer)
|
||||
{
|
||||
return new AddressCreateOrUpdateEvent(
|
||||
$data["label"],
|
||||
$data["title"],
|
||||
$data["firstname"],
|
||||
$data["lastname"],
|
||||
$data["address1"],
|
||||
$data["address2"],
|
||||
$data["address3"],
|
||||
$data["zipcode"],
|
||||
$data["city"],
|
||||
$data["country"],
|
||||
$data["cellpone"],
|
||||
$data["phone"],
|
||||
$data["company"],
|
||||
$customer
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,11 @@ 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
|
||||
{
|
||||
/**
|
||||
@@ -66,10 +71,10 @@ class CustomerController extends BaseFrontController
|
||||
$this->redirectSuccess($customerCreation);
|
||||
}
|
||||
catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $ex->getMessage());
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $ex->getMessage());
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
@@ -114,14 +119,14 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
}
|
||||
catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $ex->getMessage());
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $ex->getMessage());
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer modification process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
Tlog::getInstance()->error(sprintf("Error during customer modification process : %s.", $message));
|
||||
|
||||
$customerModification->setErrorMessage($message);
|
||||
|
||||
@@ -146,11 +151,10 @@ class CustomerController extends BaseFrontController
|
||||
$message = false;
|
||||
|
||||
$request = $this->getRequest();
|
||||
$customerLoginForm = new CustomerLogin($request);
|
||||
|
||||
try {
|
||||
|
||||
$customerLoginForm = new CustomerLogin($request);
|
||||
|
||||
$form = $this->validateForm($customerLoginForm, "post");
|
||||
|
||||
$authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);
|
||||
@@ -163,7 +167,7 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
}
|
||||
catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $ex->getMessage());
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
}
|
||||
catch(UsernameNotFoundException $e) {
|
||||
$message = "This customer email was not found.";
|
||||
@@ -175,7 +179,7 @@ class CustomerController extends BaseFrontController
|
||||
$message = "Sorry, we failed to authentify you. Please try again.";
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $ex->getMessage());
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
@@ -190,8 +194,6 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
/**
|
||||
* Perform customer logout.
|
||||
*
|
||||
* @param Customer $customer
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
@@ -203,6 +205,11 @@ class CustomerController extends BaseFrontController
|
||||
$this->redirect(URL::getIndexPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch event for customer login action
|
||||
*
|
||||
* @param Customer $customer
|
||||
*/
|
||||
protected function processLogin(Customer $customer)
|
||||
{
|
||||
$this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer));
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
namespace Thelia\Controller\Front;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -43,6 +46,16 @@ class DefaultController extends BaseFrontController
|
||||
*/
|
||||
public function noAction(Request $request)
|
||||
{
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
|
||||
/* Does the query GET parameters match a rewritten URL ? */
|
||||
$rewrittenUrl = URL::init()->retrieveCurrent($request);
|
||||
if($rewrittenUrl->rewrittenUrl !== null) {
|
||||
/* 301 redirection to rewritten URL */
|
||||
$this->redirect($rewrittenUrl->rewrittenUrl, 301);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $view = $request->query->get('view')) {
|
||||
$view = "index";
|
||||
if ($request->request->has('view')) {
|
||||
|
||||
81
core/lib/Thelia/Controller/Front/UrlRewritingController.php
Executable file
81
core/lib/Thelia/Controller/Front/UrlRewritingController.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?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\HttpFoundation\Request;
|
||||
use Thelia\Exception\UrlRewritingException;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class UrlRewritingController extends BaseFrontController
|
||||
{
|
||||
public function check(Request $request, $rewritten_url)
|
||||
{
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
try {
|
||||
$rewrittenUrlData = URL::init()->resolve($rewritten_url);
|
||||
} catch(UrlRewritingException $e) {
|
||||
switch($e->getCode()) {
|
||||
case UrlRewritingException::URL_NOT_FOUND :
|
||||
return $this->pageNotFound();
|
||||
break;
|
||||
default:
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/* is the URL redirected ? */
|
||||
|
||||
if(null !== $rewrittenUrlData->redirectedToUrl) {
|
||||
$this->redirect($rewrittenUrlData->redirectedToUrl, 301);
|
||||
}
|
||||
|
||||
/* define GET arguments in request */
|
||||
|
||||
if(null !== $rewrittenUrlData->view) {
|
||||
$request->query->set('view', $rewrittenUrlData->view);
|
||||
if(null !== $rewrittenUrlData->viewId) {
|
||||
$request->query->set($rewrittenUrlData->view . '_id', $rewrittenUrlData->viewId);
|
||||
}
|
||||
}
|
||||
if(null !== $rewrittenUrlData->locale) {
|
||||
$request->query->set('locale', $rewrittenUrlData->locale);
|
||||
}
|
||||
|
||||
foreach($rewrittenUrlData->otherParameters as $parameter => $value) {
|
||||
$request->query->set($parameter, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $view = $request->query->get('view')) {
|
||||
$view = "index";
|
||||
if ($request->request->has('view')) {
|
||||
$view = $request->request->get('view');
|
||||
}
|
||||
}
|
||||
|
||||
$request->attributes->set('_view', $view);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
60
core/lib/Thelia/Controller/Install/BaseInstallController.php
Normal file
60
core/lib/Thelia/Controller/Install/BaseInstallController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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\Install;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Controller\BaseController;
|
||||
|
||||
|
||||
/**
|
||||
* Class BaseInstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class BaseInstallController extends BaseController
|
||||
{
|
||||
/**
|
||||
* @return a ParserInterface instance parser
|
||||
*/
|
||||
protected function getParser()
|
||||
{
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template thant shoud be used
|
||||
$parser->setTemplate("install");
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
public function render($templateName, $args = array())
|
||||
{
|
||||
return new Response($this->renderRaw($templateName, $args));
|
||||
}
|
||||
|
||||
public function renderRaw($templateName, $args = array())
|
||||
{
|
||||
$data = $this->getParser()->render($templateName, $args);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
69
core/lib/Thelia/Controller/Install/InstallController.php
Normal file
69
core/lib/Thelia/Controller/Install/InstallController.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Install;
|
||||
use Thelia\Install\BaseInstall;
|
||||
use Thelia\Install\CheckPermission;
|
||||
|
||||
/**
|
||||
* Class InstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class InstallController extends BaseInstallController {
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->verifyStep(1);
|
||||
|
||||
$this->getSession()->set("step", 1);
|
||||
|
||||
$this->render("index.html");
|
||||
}
|
||||
|
||||
public function checkPermission()
|
||||
{
|
||||
$this->verifyStep(2);
|
||||
|
||||
$permission = new CheckPermission();
|
||||
}
|
||||
|
||||
protected function verifyStep($step)
|
||||
{
|
||||
$session = $this->getSession();
|
||||
|
||||
if ($session->has("step")) {
|
||||
$sessionStep = $session->get("step");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch($step) {
|
||||
case "1" :
|
||||
if ($sessionStep > 1) {
|
||||
$this->redirect("/install/step/2");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user