|
24 | 24 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
25 | 25 | use Symfony\Contracts\Translation\TranslatorInterface; |
26 | 26 |
|
27 | | -final class OrderItemController extends BaseController |
28 | | -{ |
29 | | - public function addAction(Request $request): Response |
30 | | - { |
31 | | - $cart = $this->getCurrentCart(); |
32 | | - $configuration = $this->requestConfigurationFactory->create($this->metadata, $request); |
33 | | - |
34 | | - $this->isGrantedOr403($configuration, CartActions::ADD); |
35 | | - /** @var OrderItemInterface $orderItem */ |
36 | | - $orderItem = $this->newResourceFactory->create($configuration, $this->factory); |
37 | | - |
38 | | - $this->getQuantityModifier()->modify($orderItem, 1); |
39 | | - |
40 | | - /** @var string $formType */ |
41 | | - $formType = $configuration->getFormType(); |
42 | | - |
43 | | - $form = $this->getFormFactory()->create( |
44 | | - $formType, |
45 | | - $this->createAddToCartCommand($cart, $orderItem), |
46 | | - $configuration->getFormOptions(), |
47 | | - ); |
48 | | - |
49 | | - $form->handleRequest($request); |
50 | | - |
51 | | - /** @var SubmitButton $addToWishlist */ |
52 | | - $addToWishlist = $form->get('addToWishlist'); |
53 | | - |
54 | | - if ($addToWishlist->isClicked()) { |
55 | | - /** @var AddToCartCommandInterface $addToCartCommand */ |
56 | | - $addToCartCommand = $form->getData(); |
57 | | - |
58 | | - /** @var OrderItemInterface $item */ |
59 | | - $item = $addToCartCommand->getCartItem(); |
60 | | - /** @var ?ProductVariantInterface $variant */ |
61 | | - $variant = $item->getVariant(); |
62 | | - |
63 | | - /** @var ?WishlistInterface $wishlist */ |
64 | | - $wishlist = $form->get('wishlists')->getData(); |
65 | | - |
66 | | - if (null === $variant) { |
67 | | - throw new NotFoundHttpException('Could not find variant'); |
68 | | - } |
69 | | - |
70 | | - if (null === $wishlist) { |
71 | | - /** @var Session $session */ |
72 | | - $session = $request->getSession(); |
73 | | - /** @var ?TranslatorInterface $translator */ |
74 | | - $translator = $this->get('translator'); |
75 | | - |
76 | | - if (null !== $translator) { |
77 | | - $session->getFlashBag()->add('error', $translator->trans('bitbag_sylius_wishlist_plugin.ui.go_to_wishlist_failure')); |
78 | | - } |
79 | | - |
80 | | - return new Response($this->generateUrl('sylius_shop_homepage')); |
81 | | - } |
82 | | - |
83 | | - return new Response($this->generateUrl('bitbag_sylius_wishlist_plugin_shop_locale_wishlist_add_product_variant', [ |
84 | | - 'wishlistId' => $wishlist->getId(), |
85 | | - 'variantId' => $variant->getId(), |
86 | | - ])); |
87 | | - } |
88 | | - |
89 | | - return parent::addAction($request); |
90 | | - } |
91 | | -} |
| 27 | +//final class OrderItemController extends BaseController |
| 28 | +//{ |
| 29 | +// public function addAction(Request $request): Response |
| 30 | +// { |
| 31 | +// $cart = $this->getCurrentCart(); |
| 32 | +// $configuration = $this->requestConfigurationFactory->create($this->metadata, $request); |
| 33 | +// |
| 34 | +// $this->isGrantedOr403($configuration, CartActions::ADD); |
| 35 | +// /** @var OrderItemInterface $orderItem */ |
| 36 | +// $orderItem = $this->newResourceFactory->create($configuration, $this->factory); |
| 37 | +// |
| 38 | +// $this->getQuantityModifier()->modify($orderItem, 1); |
| 39 | +// |
| 40 | +// /** @var string $formType */ |
| 41 | +// $formType = $configuration->getFormType(); |
| 42 | +// |
| 43 | +// $form = $this->getFormFactory()->create( |
| 44 | +// $formType, |
| 45 | +// $this->createAddToCartCommand($cart, $orderItem), |
| 46 | +// $configuration->getFormOptions(), |
| 47 | +// ); |
| 48 | +// |
| 49 | +// $form->handleRequest($request); |
| 50 | +// |
| 51 | +// /** @var SubmitButton $addToWishlist */ |
| 52 | +// $addToWishlist = $form->get('addToWishlist'); |
| 53 | +// |
| 54 | +// if ($addToWishlist->isClicked()) { |
| 55 | +// /** @var AddToCartCommandInterface $addToCartCommand */ |
| 56 | +// $addToCartCommand = $form->getData(); |
| 57 | +// |
| 58 | +// /** @var OrderItemInterface $item */ |
| 59 | +// $item = $addToCartCommand->getCartItem(); |
| 60 | +// /** @var ?ProductVariantInterface $variant */ |
| 61 | +// $variant = $item->getVariant(); |
| 62 | +// |
| 63 | +// /** @var ?WishlistInterface $wishlist */ |
| 64 | +// $wishlist = $form->get('wishlists')->getData(); |
| 65 | +// |
| 66 | +// if (null === $variant) { |
| 67 | +// throw new NotFoundHttpException('Could not find variant'); |
| 68 | +// } |
| 69 | +// |
| 70 | +// if (null === $wishlist) { |
| 71 | +// /** @var Session $session */ |
| 72 | +// $session = $request->getSession(); |
| 73 | +// /** @var ?TranslatorInterface $translator */ |
| 74 | +// $translator = $this->get('translator'); |
| 75 | +// |
| 76 | +// if (null !== $translator) { |
| 77 | +// $session->getFlashBag()->add('error', $translator->trans('bitbag_sylius_wishlist_plugin.ui.go_to_wishlist_failure')); |
| 78 | +// } |
| 79 | +// |
| 80 | +// return new Response($this->generateUrl('sylius_shop_homepage')); |
| 81 | +// } |
| 82 | +// |
| 83 | +// return new Response($this->generateUrl('bitbag_sylius_wishlist_plugin_shop_locale_wishlist_add_product_variant', [ |
| 84 | +// 'wishlistId' => $wishlist->getId(), |
| 85 | +// 'variantId' => $variant->getId(), |
| 86 | +// ])); |
| 87 | +// } |
| 88 | +// |
| 89 | +// return parent::addAction($request); |
| 90 | +// } |
| 91 | +//} |
0 commit comments