diff --git a/CHANGELOG.md b/CHANGELOG.md index f878527b80..d134a15947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Within V2 +## 2.0.0-RC.1 + - Flash Messages are translated in the Controllers now, not in views anymore. If you have custom Flash Messages, translate them in your Controller instead of the view. + ## 2.0.0-beta.4 - Completely remove FOSRestBundle, you still can use it, but you need to install it yourself. CoreShop only used the BodyListener to decode POST/PUT Requests, this Listener is now added by CoreShop if FOSRestBundle is not installed. diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php index cb93fa6c5f..580c4653cc 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php @@ -61,7 +61,7 @@ public function summaryAction(Request $request) $voucherCode = $this->getCartPriceRuleVoucherRepository()->findByCode($code); if (!$voucherCode instanceof CartPriceRuleVoucherCodeInterface) { - $this->addFlash('error', 'coreshop.ui.error.voucher.not_found'); + $this->addFlash('error', $this->get('translator')->trans('coreshop.ui.error.voucher.not_found')); return $this->renderTemplate($this->templateConfigurator->findTemplate('Cart/summary.html'), [ 'cart' => $this->getCart(), 'form' => $form->createView() @@ -72,12 +72,12 @@ public function summaryAction(Request $request) if ($this->getCartPriceRuleProcessor()->process($cart, $priceRule, $voucherCode)) { $this->getCartManager()->persistCart($cart); - $this->addFlash('success', 'coreshop.ui.success.voucher.stored'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.success.voucher.stored')); } else { - $this->addFlash('error', 'coreshop.ui.error.voucher.invalid'); + $this->addFlash('error', $this->get('translator')->trans('coreshop.ui.error.voucher.invalid')); } } else { - $this->addFlash('success', 'coreshop.ui.cart_updated'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.cart_updated')); } $this->get('event_dispatcher')->dispatch('coreshop.cart.update', new GenericEvent($cart)); @@ -188,7 +188,7 @@ public function addItemAction(Request $request) $this->get('coreshop.tracking.manager')->trackCartAdd($this->getCart(), $product, $quantity); - $this->addFlash('success', 'coreshop.ui.item_added'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.item_added')); return $this->redirect($redirect); } @@ -210,7 +210,7 @@ public function removeItemAction(Request $request) return $this->redirectToRoute('coreshop_index'); } - $this->addFlash('success', 'coreshop.ui.item_removed'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.item_removed')); $this->getCartModifier()->removeItem($this->getCart(), $cartItem); $this->getCartManager()->persistCart($this->getCart()); diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/CustomerController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/CustomerController.php index 3888406dc5..0273899ac9 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/CustomerController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/CustomerController.php @@ -173,7 +173,7 @@ public function addressAction(Request $request) $customer->addAddress($address); $customer->save(); - $this->addFlash('success', sprintf('coreshop.ui.customer.address_successfully_%s', $eventType === 'add' ? 'added' : 'updated')); + $this->addFlash('success', $this->get('translator')->trans(sprintf('coreshop.ui.customer.address_successfully_%s', $eventType === 'add' ? 'added' : 'updated'))); return $this->redirect($handledForm->get('_redirect')->getData() ?: $this->generateCoreShopUrl($customer, 'coreshop_customer_addresses')); } } @@ -217,7 +217,7 @@ public function addressDeleteAction(Request $request) $address->delete(); - $this->addFlash('success', 'coreshop.ui.customer.address_successfully_deleted'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.customer.address_successfully_deleted')); return $this->redirectToRoute('coreshop_customer_addresses'); } @@ -252,7 +252,7 @@ public function settingsAction(Request $request) $event ); - $this->addFlash('success', 'coreshop.ui.customer.profile_successfully_updated'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.customer.profile_successfully_updated')); return $this->redirectToRoute('coreshop_customer_profile'); } } @@ -293,7 +293,7 @@ public function changePasswordAction(Request $request) $event ); - $this->addFlash('success', 'coreshop.ui.customer.password_successfully_changed'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.customer.password_successfully_changed')); return $this->redirectToRoute('coreshop_customer_profile'); } } @@ -336,9 +336,9 @@ public function confirmNewsletterAction(Request $request) $event ); - $this->addFlash('success', 'coreshop.ui.newsletter_confirmed'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.newsletter_confirmed')); } else { - $this->addFlash('error', 'coreshop.ui.newsletter_confirmation_error'); + $this->addFlash('error', $this->get('translator')->trans('coreshop.ui.newsletter_confirmation_error')); } return $this->renderTemplate($this->templateConfigurator->findTemplate('Customer/confirm_newsletter.html'), [ diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/RegisterController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/RegisterController.php index 32a7ee441c..90a08c0f6d 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/RegisterController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/RegisterController.php @@ -105,7 +105,7 @@ public function passwordResetRequestAction(Request $request) $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch('coreshop.customer.request_password_reset', new RequestPasswordChangeEvent($customer, $resetLink)); - $this->addFlash('success', 'coreshop.ui.password_reset_request_success'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.password_reset_request_success')); return $this->redirectToRoute('coreshop_login'); } @@ -134,7 +134,7 @@ public function passwordResetAction(Request $request) $customer->setPassword($resetPassword['password']); $customer->save(); - $this->addFlash('success', 'coreshop.ui.password_reset_success'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.password_reset_success')); $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch('coreshop.customer.password_reset', new GenericEvent($customer)); diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/WishlistController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/WishlistController.php index 0940b31dc2..96a8055bf9 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/WishlistController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/WishlistController.php @@ -42,7 +42,7 @@ public function addItemAction(Request $request) $this->getWishlistModifier()->addItem($this->getWishlist(), $product, $quantity); - $this->addFlash('success', 'coreshop.ui.item_added'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.item_added')); $redirect = $request->get('_redirect', $this->generateCoreShopUrl($this->getWishlist(), 'coreshop_wishlist_summary')); return $this->redirect($redirect); @@ -61,7 +61,7 @@ public function removeItemAction(Request $request) return $this->redirectToRoute('coreshop_index'); } - $this->addFlash('success', 'coreshop.ui.item_removed'); + $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.item_removed')); $this->getWishlistModifier()->updateItemQuantity($this->getWishlist(), $product, 0); diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Common/flash_messages.html.twig b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Common/flash_messages.html.twig index a2e6081639..ac1ada6329 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Common/flash_messages.html.twig +++ b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Common/flash_messages.html.twig @@ -3,9 +3,9 @@ {% for label, message_data in app.flashes(['success', 'error']) %} {% for message in message_data %} {% if label == 'error' %} - {{ messages.error(message) }} + {{ messages.error(message, false) }} {% else %} - {{ messages.dynamic(message, label)}} + {{ messages.dynamic(message, label, false)}} {% endif %} {% endfor %} {% endfor %} \ No newline at end of file