diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php new file mode 100644 index 000000000..dab3cd4f5 --- /dev/null +++ b/core/lib/Thelia/Action/BaseAction.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Action; + +use Symfony\Component\HttpFoundation\RedirectResponse; + +abstract class BaseAction +{ + + public function redirect($url, $status = 302) + { + $response = new RedirectResponse($url, $status); + + $response->send(); + exit; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 742994a78..64f343aa2 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -39,7 +39,6 @@ use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\ConfigQuery; use Thelia\Model\Customer; -use Thelia\Tools\Redirect; /** * @@ -48,7 +47,7 @@ use Thelia\Tools\Redirect; * Class Cart * @package Thelia\Action */ -class Cart implements EventSubscriberInterface +class Cart extends BaseAction implements EventSubscriberInterface { /** * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface @@ -103,7 +102,7 @@ class Cart implements EventSubscriberInterface ->save(); ; - Redirect::exec($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1)))); + $this->redirect($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1)))); } catch (PropelException $e) { \Thelia\Log\Tlog::getInstance()->error(sptinf("error on adding item to cart with message : %s", $e->getMessage())); $message = "Impossible to add this article to your cart, please try again"; diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 6ed4b480d..21f599c37 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -37,14 +37,13 @@ use Thelia\Form\CustomerLogin; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\SecurityContext; use Thelia\Model\ConfigQuery; -use Thelia\Tools\Redirect; use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\UsernameNotFoundException; use Propel\Runtime\Exception\PropelException; -class Customer implements EventSubscriberInterface +class Customer extends BaseAction implements EventSubscriberInterface { /** * @var Thelia\Core\Security\SecurityContext @@ -291,7 +290,7 @@ class Customer implements EventSubscriberInterface if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event); // Redirect to the success URL - Redirect::exec($form->getSuccessUrl()); + $this->redirect($form->getSuccessUrl()); } /**