forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframebusy-make-checkout-a-lazy-frame.diff
45 lines (41 loc) · 2.08 KB
/
framebusy-make-checkout-a-lazy-frame.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
diff --git a/src/Controller/CheckoutController.php b/src/Controller/CheckoutController.php
index a5a4d64..5456432 100644
--- a/src/Controller/CheckoutController.php
+++ b/src/Controller/CheckoutController.php
@@ -21,13 +21,9 @@ class CheckoutController extends AbstractController
/**
* @Route("/checkout", name="app_checkout")
*/
- public function checkout(ProductRepository $productRepository, Request $request, CartStorage $cartStorage, EntityManagerInterface $entityManager, SessionInterface $session): Response
+ public function checkout(Request $request, CartStorage $cartStorage, EntityManagerInterface $entityManager, SessionInterface $session): Response
{
$checkoutForm = $this->createForm(CheckoutFormType::class);
- $featuredProduct = $productRepository->findFeatured();
- $addToCartForm = $this->createForm(AddItemToCartFormType::class, null, [
- 'product' => $featuredProduct,
- ]);
$checkoutForm->handleRequest($request);
if ($checkoutForm->isSubmitted() && $checkoutForm->isValid()) {
@@ -46,8 +42,6 @@ class CheckoutController extends AbstractController
return $this->renderForm('checkout/checkout.html.twig', [
'checkoutForm' => $checkoutForm,
- 'featuredProduct' => $featuredProduct,
- 'addToCartForm' => $addToCartForm,
]);
}
diff --git a/templates/checkout/checkout.html.twig b/templates/checkout/checkout.html.twig
index 8855953..b388218 100644
--- a/templates/checkout/checkout.html.twig
+++ b/templates/checkout/checkout.html.twig
@@ -10,9 +10,9 @@
<div class="container-fluid container-xl mt-4">
<div class="row">
<aside class="col-12 col-lg-4">
- {% if featuredProduct %}
- {{ include('cart/_featuredSidebar.html.twig') }}
- {% endif %}
+ <turbo-frame id="cart-sidebar" src="{{ path('_app_cart_product_featured') }}" target="_top">
+ Loading...
+ </turbo-frame>
</aside>
<div class="col-12 col-lg-8 cart">