Merge branch 'master' of https://github.com/thelia/thelia
Conflicts: core/lib/Thelia/Action/Category.php core/lib/Thelia/Action/Customer.php
This commit is contained in:
@@ -29,19 +29,13 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Core\Event\CartEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\HttpFoundation\Session\Session;
|
||||
use Thelia\Form\CartAdd;
|
||||
use Thelia\Model\ProductPrice;
|
||||
use Thelia\Model\ProductPriceQuery;
|
||||
use Thelia\Model\CartItem;
|
||||
use Thelia\Model\CartItemQuery;
|
||||
use Thelia\Model\CartQuery;
|
||||
use Thelia\Model\Cart as CartModel;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
use Thelia\Action\Exception\FormValidationException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -56,18 +50,18 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
/**
|
||||
*
|
||||
* add an article to cart
|
||||
* add an article in the current cart
|
||||
*
|
||||
* @param \Thelia\Core\Event\ActionEvent $event
|
||||
*/
|
||||
public function addArticle(ActionEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
$request = $event->getRequest();
|
||||
|
||||
try {
|
||||
$cartAdd = $this->getAddCartForm($request);
|
||||
try {
|
||||
$cartAdd = $this->getAddCartForm($request);
|
||||
|
||||
$form = $this->validateForm($cartAdd);
|
||||
$form = $this->validateForm($cartAdd);
|
||||
|
||||
$cart = $this->getCart($request);
|
||||
$newness = $form->get("newness")->getData();
|
||||
@@ -79,8 +73,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$cartItem = $this->findItem($cart->getId(), $productId, $productSaleElementsId);
|
||||
|
||||
if($cartItem === null || $newness)
|
||||
{
|
||||
if ($cartItem === null || $newness) {
|
||||
$productPrice = ProductPriceQuery::create()
|
||||
->filterByProductSaleElementsId($productSaleElementsId)
|
||||
->findOne()
|
||||
@@ -89,19 +82,17 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
$this->addItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice);
|
||||
}
|
||||
|
||||
if($append && $cartItem !== null) {
|
||||
if ($append && $cartItem !== null) {
|
||||
$this->updateQuantity($cartItem, $quantity);
|
||||
}
|
||||
|
||||
|
||||
$this->redirect($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1))));
|
||||
} 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) {
|
||||
} catch (FormValidationException $e) {
|
||||
|
||||
$message = $e->getMessage();
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
// The form has errors, propagate it.
|
||||
@@ -157,7 +148,6 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
return $cartAdd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Delete specify article present into cart
|
||||
@@ -194,7 +184,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
|
||||
if(null !== $cartItemId = $request->get("cartItem") && null !== $quantity = $request->get("quantity")) {
|
||||
if (null !== $cartItemId = $request->get("cartItem") && null !== $quantity = $request->get("quantity")) {
|
||||
|
||||
try {
|
||||
$cart = $this->getCart($request);
|
||||
@@ -204,7 +194,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
->filterById($cartItemId)
|
||||
->findOne();
|
||||
|
||||
if($cartItem) {
|
||||
if ($cartItem) {
|
||||
$this->updateQuantity($cartItem, $quantity);
|
||||
}
|
||||
} catch (PropelException $e) {
|
||||
@@ -243,5 +233,4 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,9 +34,12 @@ use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\AdminLog;
|
||||
use Thelia\Form\CategoryDeletionForm;
|
||||
use Thelia\Action\Exception\FormValidationException;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Map\CategoryTableMap;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
|
||||
|
||||
class Category extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -128,7 +131,7 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
// Update the logged-in user, and redirect to the success URL (exits)
|
||||
// We don-t send the login event, as the customer si already logged.
|
||||
$this->processSuccessfulLogin($event, $customer, $customerModification);
|
||||
$this->processSuccessfullLogin($event, $customer, $customerModification);
|
||||
}
|
||||
catch(PropelException $e) {
|
||||
|
||||
@@ -194,7 +197,7 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
catch(PropelException $e) {
|
||||
|
||||
Tlog::getInstance()->error(sprintf('error during deleting category ID=%s on action/modifyCustomer with message "%s"', $data['id'], $e->getMessage()));
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf('error during deleting category ID=%s on action/modifyCustomer with message "%s"', $data['id'], $e->getMessage()));
|
||||
|
||||
$message = "Failed to change your account, please try again.";
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
$customerEvent = new CustomerEvent($customer);
|
||||
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $customerEvent);
|
||||
|
||||
|
||||
if (isset($data['auto_login']) && $data['auto_login']) {
|
||||
// Connect the newly created user,and redirect to the success URL
|
||||
$this->processSuccessfulLogin($event, $customer, $customerCreationForm, true);
|
||||
@@ -191,7 +190,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
try {
|
||||
$user = $authenticator->getAuthentifiedUser();
|
||||
|
||||
$this->processSuccessfulLogin($event, $user, $customerLoginForm);
|
||||
$this->processSuccessfullLogin($event, $user, $customerLoginForm);
|
||||
}
|
||||
catch (ValidatorException $ex) {
|
||||
$message = "Missing or invalid information. Please check your input.";
|
||||
@@ -252,12 +251,15 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Stores the current user in the security context, and redirect to the
|
||||
* success_url.
|
||||
*
|
||||
* @param CustomerModel $user the logged user
|
||||
* @param ActionEvent $event
|
||||
* @param CustomerModel $user
|
||||
* @param BaseForm $form
|
||||
* @param bool $sendLoginEvent
|
||||
*/
|
||||
protected function processSuccessfulLogin(ActionEvent $event, CustomerModel $user, BaseForm $form, $sendLoginEvent = false)
|
||||
protected function processSuccessfullLogin(ActionEvent $event, CustomerModel $user, BaseForm $form, $sendLoginEvent = false)
|
||||
{
|
||||
// Success -> store user in security context
|
||||
$this->getFrontSecurityContext()->setUser($user);
|
||||
|
||||
Reference in New Issue
Block a user