private function recalculateCart(CartForm $form) { $removeItemId = $form->getRemoveItemId(); if ($removeItemId !== null) { $this->cartService->removeItemFromCart($this->cartService->getItemById($removeItemId)); } else { $values = $form->getValues(); foreach ($values->amount as $itemId => $amount) { $item = $this->cartService->getItemById($itemId); $item->setAmount($amount); $this->currentCartService->saveCurrentCart(); } } $this->flashMessage('Cart has been recalculated.'); $this->redirect('this'); }