This commit is contained in:
Manuel Raynaud
2013-09-11 08:27:40 +02:00
parent 990ab0e094
commit 70d93d1daa
155 changed files with 541 additions and 809 deletions

View File

@@ -31,7 +31,6 @@ use Thelia\Model\Base\AddressQuery;
use Thelia\Model\Customer;
use Thelia\Tools\URL;
/**
* Class AddressController
* @package Thelia\Controller\Front
@@ -64,10 +63,9 @@ class AddressController extends BaseFrontController
$this->dispatch(TheliaEvents::ADDRESS_CREATE, $event);
$this->redirectSuccess($addressCreate);
}catch (FormValidationException $e) {
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
}
catch (\Exception $e) {
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}
@@ -91,7 +89,7 @@ class AddressController extends BaseFrontController
$this->redirectToRoute("home");
}
if(null === $address_id = $request->get("address_id")) {
if (null === $address_id = $request->get("address_id")) {
$this->redirectToRoute("home");
}
@@ -108,7 +106,7 @@ class AddressController extends BaseFrontController
$this->redirectToRoute("home");
}
if($address->getCustomer()->getId() != $customer->getId()) {
if ($address->getCustomer()->getId() != $customer->getId()) {
$this->redirectToRoute("home");
}
@@ -118,10 +116,9 @@ class AddressController extends BaseFrontController
$this->dispatch(TheliaEvents::ADDRESS_UPDATE, $event);
$this->redirectSuccess($addressUpdate);
}catch (FormValidationException $e) {
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
}
catch (\Exception $e) {
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}
@@ -155,4 +152,4 @@ class AddressController extends BaseFrontController
$form->get("company")->getData()
);
}
}
}

View File

@@ -35,17 +35,19 @@ class BaseFrontController extends BaseController
*
* @see \Thelia\Controller\BaseController::getRouteFromRouter()
*/
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) {
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH)
{
return $this->getRouteFromRouter('router.front', $routeId, $parameters, $referenceType);
}
/**
* Redirect to à route ID related URL
*
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @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(), $referenceType = Router::ABSOLUTE_PATH) {
public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH)
{
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, array(), $referenceType), $urlParameters));
}
}

View File

@@ -77,7 +77,7 @@ class CartController extends BaseFrontController
$this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
$this->redirectSuccess();
} catch(PropelException $e) {
} catch (PropelException $e) {
$this->getParserContext()->setGeneralError($e->getMessage());
}
@@ -97,7 +97,6 @@ class CartController extends BaseFrontController
$this->getParserContext()->setGeneralError($e->getMessage());
}
}
/**

View File

@@ -27,19 +27,15 @@ use Thelia\Core\Event\CustomerLoginEvent;
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\UsernameNotFoundException;
use Thelia\Core\Security\SecurityContext;
use Thelia\Form\CustomerCreation;
use Thelia\Form\CustomerLogin;
use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\Customer;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Factory\ActionEventFactory;
use Thelia\Tools\URL;
use Thelia\Log\Tlog;
use Thelia\Core\Security\Exception\WrongPasswordException;
use Symfony\Component\Routing\Router;
/**
* Class CustomerController
@@ -70,11 +66,9 @@ class CustomerController extends BaseFrontController
$this->processLogin($customerCreateEvent->getCustomer());
$this->redirectSuccess($customerCreation);
}
catch (FormValidationException $e) {
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
}
catch (\Exception $e) {
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}
@@ -118,11 +112,9 @@ class CustomerController extends BaseFrontController
$this->redirectSuccess($customerModification);
}
catch (FormValidationException $e) {
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
}
catch (\Exception $e) {
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}
@@ -166,29 +158,24 @@ class CustomerController extends BaseFrontController
$this->redirectSuccess($customerLoginForm);
}
catch (FormValidationException $e) {
} catch (FormValidationException $e) {
if ($request->request->has("account")) {
$account = $request->request->get("account");
$form = $customerLoginForm->getForm();
if($account == 0 && $form->get("email")->getData() !== null) {
if ($account == 0 && $form->get("email")->getData() !== null) {
$this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData()));
}
}
$message = sprintf("Please check your input: %s", $e->getMessage());
}
catch(UsernameNotFoundException $e) {
} catch (UsernameNotFoundException $e) {
$message = "Wrong email or password. Please try again";
}
catch (WrongPasswordException $e) {
} catch (WrongPasswordException $e) {
$message = "Wrong email or password. Please try again";
}
catch(AuthenticationException $e) {
} catch (AuthenticationException $e) {
$message = "Wrong email or password. Please try again";
}
catch (\Exception $e) {
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}

View File

@@ -53,7 +53,7 @@ class DefaultController extends BaseFrontController
$view = $request->request->get('view');
}
}
if(null !== $view) {
if (null !== $view) {
$request->attributes->set('_view', $view);
}
@@ -61,11 +61,11 @@ class DefaultController extends BaseFrontController
$request->attributes->set("_view", "index");
}
if(ConfigQuery::isRewritingEnable()) {
if($request->attributes->get('_rewritten', false) === false) {
if (ConfigQuery::isRewritingEnable()) {
if ($request->attributes->get('_rewritten', false) === false) {
/* Does the query GET parameters match a rewritten URL ? */
$rewrittenUrl = URL::getInstance()->retrieveCurrent($request);
if($rewrittenUrl->rewrittenUrl !== null) {
if ($rewrittenUrl->rewrittenUrl !== null) {
/* 301 redirection to rewritten URL */
$this->redirect($rewrittenUrl->rewrittenUrl, 301);
}

View File

@@ -25,7 +25,6 @@ namespace Thelia\Controller\Front;
use Thelia\Model\ModuleQuery;
use Thelia\Tools\URL;
/**
* Class DeliveryController
* @package Thelia\Controller\Front
@@ -53,4 +52,4 @@ class DeliveryController extends BaseFrontController
$this->pageNotFound();
}
}
}
}