diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php index 37132d305b..1df0419af7 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/CartController.php @@ -21,11 +21,17 @@ use CoreShop\Bundle\OrderBundle\DTO\AddToCartInterface; use CoreShop\Bundle\OrderBundle\Factory\AddToCartFactoryInterface; use CoreShop\Bundle\OrderBundle\Form\Type\AddToCartType; +use CoreShop\Bundle\OrderBundle\Form\Type\CartListChoiceType; +use CoreShop\Bundle\OrderBundle\Form\Type\CartListType; use CoreShop\Bundle\OrderBundle\Form\Type\CartType; +use CoreShop\Bundle\OrderBundle\Form\Type\CreatedNamedCartType; use CoreShop\Bundle\OrderBundle\Form\Type\ShippingCalculatorType; use CoreShop\Bundle\ResourceBundle\Pimcore\Repository\StackRepositoryInterface; +use CoreShop\Bundle\StorageListBundle\Form\Type\StorageListChoiceType; use CoreShop\Bundle\WorkflowBundle\Manager\StateMachineManagerInterface; use CoreShop\Component\Address\Model\AddressInterface; +use CoreShop\Component\Core\Context\ShopperContextInterface; +use CoreShop\Component\Core\Currency\CurrencyStorageInterface; use CoreShop\Component\Core\Order\Modifier\CartItemQuantityModifier; use CoreShop\Component\Order\Cart\CartModifierInterface; use CoreShop\Component\Order\Cart\Rule\CartPriceRuleProcessorInterface; @@ -42,28 +48,105 @@ use CoreShop\Component\Resource\Repository\RepositoryInterface; use CoreShop\Component\Shipping\Calculator\TaxedShippingCalculatorInterface; use CoreShop\Component\Shipping\Resolver\CarriersResolverInterface; +use CoreShop\Component\StorageList\Factory\StorageListFactory; +use CoreShop\Component\StorageList\Provider\ContextProviderInterface; +use CoreShop\Component\StorageList\Storage\StorageListStorageInterface; use CoreShop\Component\StorageList\StorageListItemQuantityModifierInterface; +use CoreShop\Component\Store\Context\StoreContextInterface; use CoreShop\Component\Tracking\Tracker\TrackerInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\Form\FormError; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Session; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Contracts\Service\Attribute\SubscribedService; class CartController extends FrontendController { - public function widgetAction(Request $request): Response + public function widgetAction(Request $request, ShopperContextInterface $shopperContext): Response { + $form = $this->container->get('form.factory')->createNamed('coreshop', CartListType::class, ['cart' => $this->getCart()], [ + 'context' => $shopperContext->getContext(), + ]); + return $this->render($this->getTemplateConfigurator()->findTemplate('Cart/_widget.html'), [ 'cart' => $this->getCart(), + 'form' => $form->createView(), + ]); + } + + public function createNamedCartAction(Request $request, ShopperContextInterface $shopperContext) + { + $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); + + $form = $this->container->get('form.factory')->createNamed('coreshop', CreatedNamedCartType::class); + + if (in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'])) { + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $data = $form->getData(); + $storageList = $this->container->get('coreshop.factory.order')->createNewNamed($data['name']); + + $this->container->get('coreshop.storage_list.context_provider.order')->provideContextForStorageList($storageList); + + $this->getCartManager()->persistCart($storageList); + + $storageListStorage = $this->container->get('coreshop.storage_list.storage.order'); + $storageListStorage->setForContext($shopperContext->getContext(), $storageList); + + $this->addFlash('success', $this->container->get('translator')->trans('coreshop.ui.cart_added')); + + if ($request->isXmlHttpRequest()) { + return new JsonResponse([ + 'success' => true, + ]); + } + + return $this->redirect($request->getUri()); + } + } + + return $this->render($this->getTemplateConfigurator()->findTemplate('Cart/created_named.html'), [ + 'form' => $form->createView(), ]); } + public function selectNamedCartAction(Request $request, ShopperContextInterface $shopperContext) + { + $this->denyAccessUnlessGranted('CORESHOP_CURRENCY_SWITCH'); + + $form = $this->container->get('form.factory')->createNamed('coreshop', CartListType::class, ['cart' => $this->getCart()->getId()], [ + 'context' => $shopperContext->getContext(), + ]); + + if (in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'])) { + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $cart = $form->getData()['cart']; + + if ($cart->getCustomer()?->getUser()?->getId() !== $this->getUser()?->getId()) { + throw new AccessDeniedException(); + } + + $storageListStorage = $this->container->get('coreshop.storage_list.storage.order'); + $storageListStorage->setForContext($shopperContext->getContext(), $cart); + + return new RedirectResponse($request->headers->get('referer', $request->getSchemeAndHttpHost())); + } + } + + + return new RedirectResponse($request->headers->get('referer', $request->getSchemeAndHttpHost())); + } + public function createQuoteAction(Request $request, StateMachineManagerInterface $machineManager) { $this->denyAccessUnlessGranted('CORESHOP_QUOTE_CREATE'); @@ -393,6 +476,7 @@ public static function getSubscribedServices(): array [ new SubscribedService('coreshop.repository.stack.purchasable', StackRepositoryInterface::class, attributes: new Autowire(service: 'coreshop.repository.stack.purchasable')), new SubscribedService('coreshop.factory.order_item', OrderItemFactoryInterface::class, attributes: new Autowire(service: 'coreshop.factory.order_item')), + new SubscribedService('coreshop.factory.order', StorageListFactory::class, attributes: new Autowire(service: 'coreshop.factory.order')), new SubscribedService('coreshop.repository.order_item', RepositoryInterface::class, attributes: new Autowire(service: 'coreshop.repository.order_item')), new SubscribedService(CartItemQuantityModifier::class, CartItemQuantityModifier::class), new SubscribedService(AddToCartFactoryInterface::class, AddToCartFactoryInterface::class), @@ -403,6 +487,9 @@ public static function getSubscribedServices(): array new SubscribedService('coreshop.repository.cart_price_rule_voucher_code', CartPriceRuleVoucherRepositoryInterface::class), new SubscribedService(CartPriceRuleProcessorInterface::class, CartPriceRuleProcessorInterface::class), new SubscribedService(CartPriceRuleUnProcessorInterface::class, CartPriceRuleUnProcessorInterface::class), + new SubscribedService('coreshop.storage', CartPriceRuleUnProcessorInterface::class), + new SubscribedService('coreshop.storage_list.context_provider.order', ContextProviderInterface::class, attributes: new Autowire(service: 'coreshop.storage_list.context_provider.order')), + new SubscribedService('coreshop.storage_list.storage.order', StorageListStorageInterface::class, attributes: new Autowire(service: 'coreshop.storage_list.storage.order')), ], ); } diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/public/static/css/shop.css b/src/CoreShop/Bundle/FrontendBundle/Resources/public/static/css/shop.css index 1c4c23e94d..24d1e7f403 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Resources/public/static/css/shop.css +++ b/src/CoreShop/Bundle/FrontendBundle/Resources/public/static/css/shop.css @@ -12286,7 +12286,7 @@ hr { } /* Cart Style Starts */ -#cart .btn { +#cart > .btn { color: #383838; background: none; border: 1px solid var(--primary); @@ -12302,25 +12302,25 @@ hr { box-shadow: none; } -#cart .btn .fa-shopping-cart { +#cart > .btn .fa-shopping-cart { color: var(--primary); font-size: 22px; margin-right: 10px; vertical-align: top; } -#cart .btn span { +#cart > .btn span { color: #252a2f; font-size: 16px; text-transform: uppercase; } -#cart .btn span#cart-total { +#cart > .btn span#cart-total { color: var(--primary); padding: 0 8px 0 5px; } -#cart .btn i.fa-caret-down { +#car > .btn i.fa-caret-down { color: var(--primary); margin-left: 5px; } @@ -13923,7 +13923,7 @@ hr { padding-top: 0.8em; } -#cart .btn { +#cart > .btn { color: var(--primary); } diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Cart/_widget.html.twig b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Cart/_widget.html.twig index 06d21aa78d..36a20b816e 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Cart/_widget.html.twig +++ b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Cart/_widget.html.twig @@ -8,68 +8,99 @@ {{ currency.convertAndFormat(cart.total) }} + {{ form_start(form, {action: path('coreshop_cart_select')}) }} + {{ form_widget(form._token) }} + {{ form_end(form) }} \ No newline at end of file diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Cart/created_named.html.twig b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Cart/created_named.html.twig new file mode 100644 index 0000000000..46586c6f63 --- /dev/null +++ b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Cart/created_named.html.twig @@ -0,0 +1,17 @@ +{% extends '@CoreShopFrontend/layout.html.twig' %} +{% form_theme form 'bootstrap_4_layout.html.twig' %} + +{% block content %} + + {{ form_start(form) }} + {{ form_row(form.name, coreshop_test_form_attribute('cart-name')) }} + +
+ +
+ + {{ form_end(form) }} + +{% endblock %} diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/_addToNewWishlist.html.twig b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/_addToNewWishlist.html.twig deleted file mode 100644 index 31b1b41928..0000000000 --- a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/_addToNewWishlist.html.twig +++ /dev/null @@ -1,14 +0,0 @@ -{% form_theme form '@CoreShopFrontend/Form/theme.html.twig' %} - -{{ form_start(form, {'action': path('coreshop_new_wishlist_add', {'product': product.id})}) }} - {{ form_errors(form) }} - - {{ form_row(form.name) }} - - - - {{ form_row(form._token) }} -{{ form_end(form, {'render_rest': false}) }} - diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/_addToSelectableWishlist.html.twig b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/_addToSelectableWishlist.html.twig deleted file mode 100644 index 9b4a952042..0000000000 --- a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/_addToSelectableWishlist.html.twig +++ /dev/null @@ -1,14 +0,0 @@ -{% form_theme form '@CoreShopFrontend/Form/theme.html.twig' %} - -{{ form_start(form, {'action': path('coreshop_selectable_wishlist_add', {'product': product.id})}) }} - {{ form_errors(form) }} - - {{ form_row(form.storageList) }} - - - - {{ form_row(form._token) }} -{{ form_end(form, {'render_rest': false}) }} - diff --git a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/detail.html.twig b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/detail.html.twig index 0c2095bdd3..f5fdf312e9 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/detail.html.twig +++ b/src/CoreShop/Bundle/FrontendBundle/Resources/views/Product/detail.html.twig @@ -112,14 +112,6 @@ {{ render(url('coreshop_partial_wishlist_add', {'product': product.id|coreshop_string})) }} {% endif %} -{# {% if wishlist_allowed %}#} -{# {{ render(url('coreshop_partial_selectable_wishlist_add', {'product': product.id})) }}#} -{# {% endif %}#} - -{# {% if wishlist_allowed %}#} -{# {{ render(url('coreshop_partial_new_wishlist_add', {'product': product.id})) }}#} -{# {% endif %}#} - {% if cart_allowed %} {{ render(url('coreshop_partial_cart_add', {'product': product.id|coreshop_string})) }} {% endif %} diff --git a/src/CoreShop/Bundle/OrderBundle/EventListener/SessionCartSubscriber.php b/src/CoreShop/Bundle/OrderBundle/EventListener/SessionCartSubscriber.php new file mode 100644 index 0000000000..6aa808ae9b --- /dev/null +++ b/src/CoreShop/Bundle/OrderBundle/EventListener/SessionCartSubscriber.php @@ -0,0 +1,81 @@ + ['onKernelResponse'], + ]; + } + + public function onKernelResponse(ResponseEvent $event): void + { + if ($this->pimcoreContext->matchesPimcoreContext($event->getRequest(), PimcoreContextResolver::CONTEXT_ADMIN)) { + return; + } + + if (!$event->isMainRequest()) { + return; + } + + if ($event->getRequest()->attributes->get('_route') === '_wdt') { + return; + } + + /** @var Request $request */ + $request = $event->getRequest(); + + if (!$request->hasSession()) { + return; + } + + try { + $cart = $this->cartContext->getCart(); + } catch (CartNotFoundException) { + return; + } + + if (0 !== $cart->getId() && null !== $cart->getId() && null !== $cart->getStore()) { + $session = $request->getSession(); + + $session->set( + sprintf('%s.%s', $this->sessionKeyName, $cart->getStore()->getId()), + $cart->getId(), + ); + } + } +} \ No newline at end of file diff --git a/src/CoreShop/Component/StorageList/Factory/AddToNewStorageListFactoryInterface.php b/src/CoreShop/Bundle/OrderBundle/Form/Type/CartListChoiceType.php similarity index 56% rename from src/CoreShop/Component/StorageList/Factory/AddToNewStorageListFactoryInterface.php rename to src/CoreShop/Bundle/OrderBundle/Form/Type/CartListChoiceType.php index 36459d3cec..de3ff68493 100644 --- a/src/CoreShop/Component/StorageList/Factory/AddToNewStorageListFactoryInterface.php +++ b/src/CoreShop/Bundle/OrderBundle/Form/Type/CartListChoiceType.php @@ -16,14 +16,10 @@ * */ -namespace CoreShop\Component\StorageList\Factory; +namespace CoreShop\Bundle\OrderBundle\Form\Type; -use CoreShop\Component\StorageList\DTO\AddToNewStorageListInterface; -use CoreShop\Component\StorageList\Model\StorageListItemInterface; +use CoreShop\Bundle\StorageListBundle\Form\Type\StorageListChoiceType; -interface AddToNewStorageListFactoryInterface +final class CartListChoiceType extends StorageListChoiceType { - public function createWithStorageListItem( - StorageListItemInterface $storageListItem, - ): AddToNewStorageListInterface; } diff --git a/src/CoreShop/Bundle/WishlistBundle/Form/Type/AddToSelectableWishlistType.php b/src/CoreShop/Bundle/OrderBundle/Form/Type/CartListType.php similarity index 57% rename from src/CoreShop/Bundle/WishlistBundle/Form/Type/AddToSelectableWishlistType.php rename to src/CoreShop/Bundle/OrderBundle/Form/Type/CartListType.php index c0a96d0045..d096045458 100644 --- a/src/CoreShop/Bundle/WishlistBundle/Form/Type/AddToSelectableWishlistType.php +++ b/src/CoreShop/Bundle/OrderBundle/Form/Type/CartListType.php @@ -16,19 +16,23 @@ * */ -namespace CoreShop\Bundle\WishlistBundle\Form\Type; +namespace CoreShop\Bundle\OrderBundle\Form\Type; -use CoreShop\Bundle\StorageListBundle\Form\Type\AddToSelectableStorageListType; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\Valid; +use Symfony\Component\OptionsResolver\OptionsResolver; -final class AddToSelectableWishlistType extends AddToSelectableStorageListType +final class CartListType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('storageListItem', WishlistItemType::class, [ - 'constraints' => [new Valid(['groups' => $this->validationGroups])], + $builder->add('cart', CartListChoiceType::class, [ + 'context' => $options['context'], ]); - $builder->add('storageList', WishlistChoiceType::class); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefault('context', []); } } diff --git a/src/CoreShop/Bundle/WishlistBundle/Form/Type/AddToNewWishlistType.php b/src/CoreShop/Bundle/OrderBundle/Form/Type/CreatedNamedCartType.php similarity index 63% rename from src/CoreShop/Bundle/WishlistBundle/Form/Type/AddToNewWishlistType.php rename to src/CoreShop/Bundle/OrderBundle/Form/Type/CreatedNamedCartType.php index fccd4ffc30..aec09a5b7a 100644 --- a/src/CoreShop/Bundle/WishlistBundle/Form/Type/AddToNewWishlistType.php +++ b/src/CoreShop/Bundle/OrderBundle/Form/Type/CreatedNamedCartType.php @@ -16,20 +16,16 @@ * */ -namespace CoreShop\Bundle\WishlistBundle\Form\Type; +namespace CoreShop\Bundle\OrderBundle\Form\Type; -use CoreShop\Bundle\StorageListBundle\Form\Type\AddToSelectableStorageListType; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\Valid; -final class AddToNewWishlistType extends AddToSelectableStorageListType +final class CreatedNamedCartType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('storageListItem', WishlistItemType::class, [ - 'constraints' => [new Valid(['groups' => $this->validationGroups])], - ]); $builder->add('name', TextType::class); } } diff --git a/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php b/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php index e05cfa327d..8c623ccbe7 100644 --- a/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php +++ b/src/CoreShop/Bundle/OrderBundle/Pimcore/Repository/OrderRepository.php @@ -42,9 +42,9 @@ public function findLatestByStoreAndCustomer( public function findNamedStorageLists(StoreInterface $store, CustomerInterface $customer): array { $list = $this->getList(); - $list->setCondition('customer__id = ? AND store = ? AND name IS NOT NULL', [$customer->getId(), $store->getId()]); - $list->setOrderKey('o_creationDate'); - $list->setOrder('DESC'); + $list->setCondition('customer__id = ? AND store = ?', [$customer->getId(), $store->getId()]); + $list->setOrderKey('creationDate'); + $list->setOrder('ASC'); $list->load(); return $list->getObjects(); diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/config.yml b/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/config.yml index 6705a718c9..3a92c411f6 100755 --- a/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/config.yml +++ b/src/CoreShop/Bundle/OrderBundle/Resources/config/pimcore/config.yml @@ -26,6 +26,7 @@ core_shop_storage_list: services: manager: CoreShop\Bundle\OrderBundle\Manager\CartManager modifier: CoreShop\Component\Order\Cart\CartModifier + list_resolver: CoreShop\Component\Order\Cart\CartResolver session: enabled: true key: 'coreshop.cart' diff --git a/src/CoreShop/Bundle/OrderBundle/Resources/config/services/cart.yml b/src/CoreShop/Bundle/OrderBundle/Resources/config/services/cart.yml index 958742105c..9334d21219 100644 --- a/src/CoreShop/Bundle/OrderBundle/Resources/config/services/cart.yml +++ b/src/CoreShop/Bundle/OrderBundle/Resources/config/services/cart.yml @@ -59,3 +59,14 @@ services: tags: - { name: kernel.event_listener, event: pimcore.admin.object.list.beforeListLoad, method: checkObjectList } + + CoreShop\Bundle\OrderBundle\Form\Type\CartListChoiceType: + arguments: + - '@CoreShop\Component\Order\Cart\CartResolver' + tags: + - { name: form.type } + + CoreShop\Component\Order\Cart\CartResolver: + arguments: + - '@coreshop.repository.order' + - '@CoreShop\Component\Order\Context\CartContext' diff --git a/src/CoreShop/Bundle/StorageListBundle/Controller/StorageListController.php b/src/CoreShop/Bundle/StorageListBundle/Controller/StorageListController.php index 215eff1f38..91b57dd8a0 100644 --- a/src/CoreShop/Bundle/StorageListBundle/Controller/StorageListController.php +++ b/src/CoreShop/Bundle/StorageListBundle/Controller/StorageListController.php @@ -21,12 +21,7 @@ use CoreShop\Component\Resource\Model\ResourceInterface; use CoreShop\Component\Resource\Repository\RepositoryInterface; use CoreShop\Component\StorageList\Context\StorageListContextInterface; -use CoreShop\Component\StorageList\Core\Repository\CustomerAndStoreAwareRepositoryInterface; -use CoreShop\Component\StorageList\DTO\AddToNewStorageListInterface; -use CoreShop\Component\StorageList\DTO\AddToSelectableStorageListInterface; use CoreShop\Component\StorageList\DTO\AddToStorageListInterface; -use CoreShop\Component\StorageList\Factory\AddToNewStorageListFactoryInterface; -use CoreShop\Component\StorageList\Factory\AddToSelectableStorageListFactoryInterface; use CoreShop\Component\StorageList\Factory\AddToStorageListFactoryInterface; use CoreShop\Component\StorageList\Factory\StorageListFactoryInterface; use CoreShop\Component\StorageList\Factory\StorageListItemFactoryInterface; @@ -72,202 +67,12 @@ public function __construct( protected string $templateAddToList, protected string $templateSummary, protected StorageListResolverInterface $listResolver, - protected string $addToSelectableStorageListForm, - protected AddToSelectableStorageListFactoryInterface $addToSelectableStorageListFactory, - protected string $templateAddSelectableToList, - protected string $addToNewStorageListForm, - protected AddToNewStorageListFactoryInterface $addToNewStorageListFactory, - protected string $templateAddToNewList, protected ContextProviderInterface $contextProvider, protected TranslatorInterface $translator, ) { $this->setContainer($container); } - public function addToNewNamedListAction(Request $request): Response - { - $this->denyAccessUnlessGranted(sprintf('CORESHOP_%s', strtoupper($this->identifier))); - $this->denyAccessUnlessGranted(sprintf('CORESHOP_%s_ADD_ITEM', strtoupper($this->identifier))); - - $redirect = $this->getParameterFromRequest($request, '_redirect', $this->generateUrl($this->summaryRoute)); - $product = $this->productRepository->find($this->getParameterFromRequest($request, 'product')); - - if (!$product instanceof ResourceInterface) { - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => false, - ]); - } - - return $this->redirect($redirect); - } - - $item = $this->storageListItemFactory->createWithStorageListProduct($product); - - $addToNewStorageList = $this->createAddToNewStorageList($item); - - $form = $this->formFactory->createNamed( - 'coreshop-' . $product->getId(), - $this->addToNewStorageListForm, - $addToNewStorageList, - ); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - /** - * @var AddToNewStorageListInterface $addToNewStorageList - */ - $addToNewStorageList = $form->getData(); - - /** - * @var StorageListInterface $storageList - */ - $storageList = $this->storageListFactory->createNewNamed($addToNewStorageList->getName()); - - $this->contextProvider->provideContextForStorageList($storageList); - - $this->modifier->addToList($storageList, $addToNewStorageList->getStorageListItem()); - $this->manager->persist($storageList); - - $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.'.$this->identifier.'.created')); - - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => true, - ]); - } - - $redirect = $this->getParameterFromRequest($request, '_redirect', $this->generateUrl($this->summaryRoute, ['identifier' => $storageList->getName()])); - - return $this->redirect($redirect); - } - - /** - * @var FormError $error - */ - foreach ($form->getErrors(true, true) as $error) { - $this->addFlash('error', $error->getMessage()); - } - - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => false, - 'errors' => array_map(static function (FormError $error) { - return $error->getMessage(); - }, iterator_to_array($form->getErrors(true))), - ]); - } - - return $this->redirect($redirect); - } - - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => false, - ]); - } - - $template = $this->getParameterFromRequest($request, 'template', $this->templateAddToNewList); - - return $this->render( - $template, - [ - 'form' => $form->createView(), - 'product' => $product, - ], - ); - } - - public function addItemToNamedListAction(Request $request): Response - { - $this->denyAccessUnlessGranted(sprintf('CORESHOP_%s', strtoupper($this->identifier))); - $this->denyAccessUnlessGranted(sprintf('CORESHOP_%s_ADD_ITEM', strtoupper($this->identifier))); - - $product = $this->productRepository->find($this->getParameterFromRequest($request, 'product')); - $redirect = $this->getParameterFromRequest($request, '_redirect', $this->generateUrl($this->summaryRoute)); - - if (!$product instanceof ResourceInterface) { - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => false, - ]); - } - - return $this->redirect($redirect); - } - - $item = $this->storageListItemFactory->createWithStorageListProduct($product); - $addToSelectableStorageList = $this->createAddToSelectableStorageList($item); - - $form = $this->formFactory->createNamed( - 'coreshop-' . $product->getId(), - $this->addToSelectableStorageListForm, - $addToSelectableStorageList, - ); - - if ($request->isMethod('POST')) { - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - /** - * @var AddToSelectableStorageListInterface $addToSelectableStorageList - */ - $addToSelectableStorageList = $form->getData(); - - $this->modifier->addToList($addToSelectableStorageList->getStorageList(), $addToSelectableStorageList->getStorageListItem()); - $this->manager->persist($addToSelectableStorageList->getStorageList()); - - $this->addFlash('success', $this->get('translator')->trans('coreshop.ui.item_added')); - - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => true, - ]); - } - - $redirect = $this->getParameterFromRequest($request, '_redirect', $this->generateUrl($this->summaryRoute, ['identifier' => $addToSelectableStorageList->getStorageList()->getName()])); - - return $this->redirect($redirect); - } - - /** - * @var FormError $error - */ - foreach ($form->getErrors(true, true) as $error) { - $this->addFlash('error', $error->getMessage()); - } - - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => false, - 'errors' => array_map(static function (FormError $error) { - return $error->getMessage(); - }, iterator_to_array($form->getErrors(true))), - ]); - } - - return $this->redirect($redirect); - } - - if ($request->isXmlHttpRequest()) { - return new JsonResponse([ - 'success' => false, - ]); - } - - $template = $this->getParameterFromRequest($request, 'template', $this->templateAddSelectableToList); - - return $this->render( - $template, - [ - 'form' => $form->createView(), - 'product' => $product, - ], - ); - } - public function addItemAction(Request $request): Response { $privilege = sprintf('CORESHOP_%s', strtoupper($this->identifier)); @@ -406,12 +211,6 @@ public function summaryAction(Request $request): Response $list = $repository->findByToken($request->attributes->get('identifier')); $isSharedList = true; - //Try By Name - if ((null === $list) && $repository instanceof CustomerAndStoreAwareRepositoryInterface) { - $list = $this->listResolver->findNamed($request->attributes->get('identifier')); - $isSharedList = false; - } - if (null === $list) { throw new NotFoundHttpException(); } @@ -473,18 +272,6 @@ protected function createAddToStorageList( return $this->addToStorageListFactory->createWithStorageListAndStorageListItem($storageList, $storageListItem); } - protected function createAddToSelectableStorageList( - StorageListItemInterface $storageListItem, - ): AddToSelectableStorageListInterface { - return $this->addToSelectableStorageListFactory->createWithStorageListItem($storageListItem); - } - - protected function createAddToNewStorageList( - StorageListItemInterface $storageListItem, - ): AddToNewStorageListInterface { - return $this->addToNewStorageListFactory->createWithStorageListItem($storageListItem); - } - /** * @return mixed * diff --git a/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/Configuration.php b/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/Configuration.php index bdb8866fcb..7adc95c60f 100644 --- a/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/Configuration.php +++ b/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/Configuration.php @@ -21,9 +21,6 @@ use CoreShop\Bundle\StorageListBundle\Controller\StorageListController; use CoreShop\Component\StorageList\Context\CompositeStorageListContext; use CoreShop\Component\StorageList\Context\StorageListContextInterface; -use CoreShop\Component\StorageList\Core\Context\PimcoreListResolver; -use CoreShop\Component\StorageList\Factory\AddToNewStorageListFactory; -use CoreShop\Component\StorageList\Factory\AddToSelectableStorageListFactory; use CoreShop\Component\StorageList\Factory\AddToStorageListFactory; use CoreShop\Component\StorageList\SessionStorageManager; use CoreShop\Component\StorageList\StorageListModifierInterface; @@ -85,8 +82,6 @@ private function addStorageListSection(ArrayNodeDefinition $node): void ->scalarNode('factory')->cannotBeEmpty()->isRequired()->end() ->scalarNode('item_factory')->cannotBeEmpty()->isRequired()->end() ->scalarNode('add_to_list_factory')->defaultValue(AddToStorageListFactory::class)->cannotBeEmpty()->end() - ->scalarNode('add_to_selectable_list_factory')->defaultValue(AddToSelectableStorageListFactory::class)->cannotBeEmpty()->end() - ->scalarNode('add_to_new_list_factory')->defaultValue(AddToNewStorageListFactory::class)->cannotBeEmpty()->end() ->end() ->end() ->arrayNode('form') @@ -94,8 +89,6 @@ private function addStorageListSection(ArrayNodeDefinition $node): void ->children() ->scalarNode('type')->cannotBeEmpty()->end() ->scalarNode('add_type')->cannotBeEmpty()->end() - ->scalarNode('add_selectable_type')->cannotBeEmpty()->end() - ->scalarNode('add_new_type')->cannotBeEmpty()->end() ->end() ->end() ->arrayNode('routes') @@ -109,9 +102,7 @@ private function addStorageListSection(ArrayNodeDefinition $node): void ->addDefaultsIfNotSet() ->children() ->scalarNode('add_to_cart')->cannotBeEmpty()->end() - ->scalarNode('add_to_selectable_list')->cannotBeEmpty()->end() ->scalarNode('summary')->cannotBeEmpty()->end() - ->scalarNode('add_to_new_list')->cannotBeEmpty()->end() ->end() ->end() ->arrayNode('session') @@ -137,13 +128,6 @@ private function addStorageListSection(ArrayNodeDefinition $node): void ->variableNode('params')->defaultValue([])->end() ->end() ->end() - ->arrayNode('list_resolver') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('enabled')->defaultFalse()->end() - ->scalarNode('class')->defaultValue(StorageListController::class)->end() - ->end() - ->end() ->end() ->end() ->end() diff --git a/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php b/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php index a3b8fec778..e5a558ecda 100644 --- a/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php +++ b/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php @@ -152,12 +152,6 @@ public function load(array $configs, ContainerBuilder $container): void $controllerDefinition->setArgument('$templateSummary', $list['templates']['summary']); $controllerDefinition->setArgument('$templateAddToList', $list['templates']['add_to_cart']); $controllerDefinition->setArgument('$listResolver', new Reference($list['services']['list_resolver'])); - $controllerDefinition->setArgument('$addToSelectableStorageListForm', $list['form']['add_selectable_type']); - $controllerDefinition->setArgument('$addToSelectableStorageListFactory', new Reference($list['resource']['add_to_selectable_list_factory'])); - $controllerDefinition->setArgument('$templateAddSelectableToList', $list['templates']['add_to_selectable_list']); - $controllerDefinition->setArgument('$addToNewStorageListForm', $list['form']['add_new_type']); - $controllerDefinition->setArgument('$addToNewStorageListFactory', new Reference($list['resource']['add_to_new_list_factory'])); - $controllerDefinition->setArgument('$templateAddToNewList', $list['templates']['add_to_new_list']); $controllerDefinition->setArgument('$contextProvider', new Reference('coreshop.storage_list.context_provider.' . $name)); $controllerDefinition->setArgument('$translator', new Reference('translator')); $controllerDefinition->addTag('controller.service_arguments'); diff --git a/src/CoreShop/Bundle/StorageListBundle/Form/Type/AddToNewStorageListType.php b/src/CoreShop/Bundle/StorageListBundle/Form/Type/AddToNewStorageListType.php deleted file mode 100644 index f3a8decbdd..0000000000 --- a/src/CoreShop/Bundle/StorageListBundle/Form/Type/AddToNewStorageListType.php +++ /dev/null @@ -1,48 +0,0 @@ -add('name', TextType::class, [ - 'label' => 'coreshop.form.storage_list.name', - ]) - ->add('storageListItem', StorageListItemType::class, [ - 'constraints' => [new Valid(['groups' => $this->validationGroups])], - ]); - } - - public function configureOptions(OptionsResolver $resolver): void - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'csrf_protection' => true, - ]); - } -} diff --git a/src/CoreShop/Bundle/StorageListBundle/Form/Type/AddToSelectableStorageListType.php b/src/CoreShop/Bundle/StorageListBundle/Form/Type/AddToSelectableStorageListType.php deleted file mode 100644 index 9ae9277bdc..0000000000 --- a/src/CoreShop/Bundle/StorageListBundle/Form/Type/AddToSelectableStorageListType.php +++ /dev/null @@ -1,49 +0,0 @@ -add('storageListItem', StorageListItemType::class, [ - 'constraints' => [new Valid(['groups' => $this->validationGroups])], - ]); - $builder->add('storageList', StorageListChoiceType::class); - } - - public function configureOptions(OptionsResolver $resolver): void - { - parent::configureOptions($resolver); - - $resolver->setDefaults([ - 'csrf_protection' => true, - ]); - } - - public function getBlockPrefix(): string - { - return 'coreshop_add_to_storage_list'; - } -} diff --git a/src/CoreShop/Bundle/StorageListBundle/Form/Type/StorageListChoiceType.php b/src/CoreShop/Bundle/StorageListBundle/Form/Type/StorageListChoiceType.php index 67ef1aca0b..72f4302da2 100644 --- a/src/CoreShop/Bundle/StorageListBundle/Form/Type/StorageListChoiceType.php +++ b/src/CoreShop/Bundle/StorageListBundle/Form/Type/StorageListChoiceType.php @@ -37,8 +37,9 @@ public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ + 'context' => [], 'choices' => function (Options $options) { - return $this->listResolver->getStorageLists(); + return $this->listResolver->getStorageLists($options['context']); }, 'choice_value' => 'token', 'choice_label' => function (StorageListInterface $list) { @@ -50,6 +51,7 @@ public function configureOptions(OptionsResolver $resolver): void }, 'choice_translation_domain' => false, 'active' => true, + 'expanded' => true ]); } diff --git a/src/CoreShop/Bundle/WishlistBundle/Resources/config/pimcore/config.yml b/src/CoreShop/Bundle/WishlistBundle/Resources/config/pimcore/config.yml index a02c29dbc8..feac820569 100644 --- a/src/CoreShop/Bundle/WishlistBundle/Resources/config/pimcore/config.yml +++ b/src/CoreShop/Bundle/WishlistBundle/Resources/config/pimcore/config.yml @@ -14,8 +14,6 @@ core_shop_storage_list: form: type: CoreShop\Bundle\WishlistBundle\Form\Type\WishlistType add_type: CoreShop\Bundle\WishlistBundle\Form\Type\AddToWishlistType - add_selectable_type: CoreShop\Bundle\WishlistBundle\Form\Type\AddToSelectableWishlistType - add_new_type: CoreShop\Bundle\WishlistBundle\Form\Type\AddToNewWishlistType resource: interface: '%coreshop.interface.wishlist%' product_repository: coreshop.repository.stack.wishlist_product @@ -28,8 +26,6 @@ core_shop_storage_list: index: coreshop_index templates: add_to_cart: '@CoreShopFrontend/Product/_addToWishlist.html.twig' - add_to_selectable_list: '@CoreShopFrontend/Product/_addToSelectableWishlist.html.twig' - add_to_new_list: '@CoreShopFrontend/Product/_addToNewWishlist.html.twig' summary: '@CoreShopFrontend/Wishlist/summary.html.twig' controller: enabled: true diff --git a/src/CoreShop/Bundle/WishlistBundle/Resources/config/services.yml b/src/CoreShop/Bundle/WishlistBundle/Resources/config/services.yml index e9db073933..dfd459014e 100644 --- a/src/CoreShop/Bundle/WishlistBundle/Resources/config/services.yml +++ b/src/CoreShop/Bundle/WishlistBundle/Resources/config/services.yml @@ -68,7 +68,6 @@ services: CoreShop\Component\Wishlist\Wishlist\WishlistResolver: arguments: - '@coreshop.repository.wishlist' - - '@CoreShop\Component\Core\Context\ShopperContextInterface' - '@coreshop.context.storage_list.wishlist' CoreShop\Bundle\WishlistBundle\Form\Type\AddToSelectableWishlistType: diff --git a/src/CoreShop/Component/StorageList/Factory/AddToSelectableStorageListFactoryInterface.php b/src/CoreShop/Component/Order/Cart/CartResolver.php similarity index 55% rename from src/CoreShop/Component/StorageList/Factory/AddToSelectableStorageListFactoryInterface.php rename to src/CoreShop/Component/Order/Cart/CartResolver.php index c09261f9f5..1387826a40 100644 --- a/src/CoreShop/Component/StorageList/Factory/AddToSelectableStorageListFactoryInterface.php +++ b/src/CoreShop/Component/Order/Cart/CartResolver.php @@ -16,14 +16,10 @@ * */ -namespace CoreShop\Component\StorageList\Factory; +namespace CoreShop\Component\Order\Cart; -use CoreShop\Component\StorageList\DTO\AddToSelectableStorageList; -use CoreShop\Component\StorageList\Model\StorageListItemInterface; +use CoreShop\Component\StorageList\Core\Context\PimcoreListResolver; -interface AddToSelectableStorageListFactoryInterface +class CartResolver extends PimcoreListResolver { - public function createWithStorageListItem( - StorageListItemInterface $storageListItem, - ): AddToSelectableStorageList; -} +} \ No newline at end of file diff --git a/src/CoreShop/Component/Order/Factory/OrderFactory.php b/src/CoreShop/Component/Order/Factory/OrderFactory.php index 340fd3d2f1..ba68720e92 100644 --- a/src/CoreShop/Component/Order/Factory/OrderFactory.php +++ b/src/CoreShop/Component/Order/Factory/OrderFactory.php @@ -25,8 +25,11 @@ use CoreShop\Component\Order\OrderStates; use CoreShop\Component\Resource\Factory\FactoryInterface; use CoreShop\Component\Resource\TokenGenerator\UniqueTokenGenerator; +use CoreShop\Component\StorageList\Factory\StorageListFactoryInterface; +use CoreShop\Component\StorageList\Model\NameableStorageListInterface; +use CoreShop\Component\StorageList\Model\StorageListInterface; -class OrderFactory implements FactoryInterface +class OrderFactory implements StorageListFactoryInterface { public function __construct( private FactoryInterface $cartFactory, @@ -49,4 +52,18 @@ public function createNew() return $cart; } + + public function createNewNamed(string $name) + { + /** + * @var StorageListInterface $storageList + */ + $storageList = $this->createNew(); + + if ($storageList instanceof NameableStorageListInterface) { + $storageList->setName($name); + } + + return $storageList; + } } diff --git a/src/CoreShop/Component/Order/Model/OrderInterface.php b/src/CoreShop/Component/Order/Model/OrderInterface.php index 0d183a7bd5..956a5a652f 100644 --- a/src/CoreShop/Component/Order/Model/OrderInterface.php +++ b/src/CoreShop/Component/Order/Model/OrderInterface.php @@ -28,6 +28,7 @@ use CoreShop\Component\Payment\Model\PaymentProviderInterface; use CoreShop\Component\Resource\Model\ImmutableInterface; use CoreShop\Component\Resource\Pimcore\Model\PimcoreModelInterface; +use CoreShop\Component\StorageList\Model\NameableStorageListInterface; use CoreShop\Component\StorageList\Model\StorageListInterface; use CoreShop\Component\Store\Model\StoreAwareInterface; use Pimcore\Model\DataObject\Fieldcollection; @@ -43,7 +44,8 @@ interface OrderInterface extends CustomerAwareInterface, PayableInterface, StorageListInterface, - ImmutableInterface + ImmutableInterface, + NameableStorageListInterface { public function getId(): ?int; diff --git a/src/CoreShop/Component/StorageList/Core/Context/PimcoreListResolver.php b/src/CoreShop/Component/StorageList/Core/Context/PimcoreListResolver.php index 57e5b74b94..0293137536 100644 --- a/src/CoreShop/Component/StorageList/Core/Context/PimcoreListResolver.php +++ b/src/CoreShop/Component/StorageList/Core/Context/PimcoreListResolver.php @@ -18,42 +18,46 @@ namespace CoreShop\Component\StorageList\Core\Context; -use CoreShop\Component\Core\Context\ShopperContextInterface; use CoreShop\Component\StorageList\Context\StorageListContextInterface; use CoreShop\Component\StorageList\Core\Repository\CustomerAndStoreAwareRepositoryInterface; use CoreShop\Component\StorageList\Model\StorageListInterface; use CoreShop\Component\StorageList\Resolver\StorageListResolverInterface; +use Webmozart\Assert\Assert; class PimcoreListResolver implements StorageListResolverInterface { public function __construct( protected CustomerAndStoreAwareRepositoryInterface $repository, - protected ShopperContextInterface $context, protected StorageListContextInterface $storageListContext, ) { } - public function getStorageLists(): array + public function getStorageLists(array $context): array { - if (!$this->context->hasCustomer()) { + Assert::keyExists($context, 'store'); + + if (!isset($context['customer'])) { return [$this->storageListContext->getStorageList()]; } - $namedLists = $this->repository->findNamedStorageLists($this->context->getStore(), $this->context->getCustomer()); - - $defaultList = $this->storageListContext->getStorageList(); - array_unshift($namedLists, $defaultList); + $store = $context['store']; + $customer = $context['customer']; - return $namedLists; + return $this->repository->findNamedStorageLists($store, $customer); } - public function findNamed(string $name): ?StorageListInterface + public function findNamed(array $context, string $name): ?StorageListInterface { - if (!$this->context->hasCustomer()) { + Assert::keyExists($context, 'store'); + + if (!isset($context['customer'])) { return null; } - return $this->repository->findLatestByStoreAndCustomer($this->context->getStore(), $this->context->getCustomer(), $name); + $store = $context['store']; + $customer = $context['customer']; + + return $this->repository->findLatestByStoreAndCustomer($store, $customer, $name); } } \ No newline at end of file diff --git a/src/CoreShop/Component/StorageList/Core/Context/SessionAndStoreBasedStorageListContext.php b/src/CoreShop/Component/StorageList/Core/Context/SessionAndStoreBasedStorageListContext.php index dbf5a4972b..51a703dae4 100644 --- a/src/CoreShop/Component/StorageList/Core/Context/SessionAndStoreBasedStorageListContext.php +++ b/src/CoreShop/Component/StorageList/Core/Context/SessionAndStoreBasedStorageListContext.php @@ -38,7 +38,7 @@ public function __construct( public function getStorageList(): StorageListInterface { - if (null !== $this->storageList) { + if (null !== $this->storageList && !$this->storageListStorage->gotReset()) { return $this->storageList; } diff --git a/src/CoreShop/Component/StorageList/Core/Provider/CoreContextProvider.php b/src/CoreShop/Component/StorageList/Core/Provider/CoreContextProvider.php index 79faaa514e..89bbecc3c4 100644 --- a/src/CoreShop/Component/StorageList/Core/Provider/CoreContextProvider.php +++ b/src/CoreShop/Component/StorageList/Core/Provider/CoreContextProvider.php @@ -19,6 +19,7 @@ namespace CoreShop\Component\StorageList\Core\Provider; use CoreShop\Component\Core\Context\ShopperContextInterface; +use CoreShop\Component\Currency\Model\CurrencyAwareInterface; use CoreShop\Component\Customer\Context\CustomerNotFoundException; use CoreShop\Component\Customer\Model\CustomerAwareInterface; use CoreShop\Component\StorageList\Model\StorageListInterface; @@ -43,6 +44,10 @@ public function provideContextForStorageList(StorageListInterface $storageList): } } + if ($storageList instanceof CurrencyAwareInterface) { + $currency = $this->shopperContext->getCurrency(); + $storageList->setCurrency($currency); + } if (($storageList instanceof CustomerAwareInterface) && $this->shopperContext->hasCustomer()) { $customer = $this->shopperContext->getCustomer(); diff --git a/src/CoreShop/Component/StorageList/Core/Storage/SessionStorageListStorage.php b/src/CoreShop/Component/StorageList/Core/Storage/SessionStorageListStorage.php index 8067ab46ee..3f4e99a776 100644 --- a/src/CoreShop/Component/StorageList/Core/Storage/SessionStorageListStorage.php +++ b/src/CoreShop/Component/StorageList/Core/Storage/SessionStorageListStorage.php @@ -28,6 +28,8 @@ class SessionStorageListStorage implements StorageListStorageInterface { + private bool $gotReset = true; + public function __construct( private RequestStack $requestStack, private string $sessionKeyName, @@ -40,8 +42,14 @@ public function hasForContext(array $context): bool return $this->getSession()->has($this->getKeyName($context)); } + public function gotReset(): bool + { + return $this->gotReset; + } + public function getForContext(array $context): ?StorageListInterface { + $this->gotReset = false; if ($this->hasForContext($context)) { $storageListId = $this->getSession()->get($this->getKeyName($context)); @@ -57,6 +65,7 @@ public function getForContext(array $context): ?StorageListInterface public function setForContext(array $context, StorageListInterface $storageList): void { + $this->gotReset = true; $this->getSession()->set($this->getKeyName($context), $storageList->getId()); } diff --git a/src/CoreShop/Component/StorageList/Factory/AddToNewStorageListFactory.php b/src/CoreShop/Component/StorageList/Factory/AddToNewStorageListFactory.php deleted file mode 100644 index 08cf53a5b2..0000000000 --- a/src/CoreShop/Component/StorageList/Factory/AddToNewStorageListFactory.php +++ /dev/null @@ -1,49 +0,0 @@ -addToNewStorageListClass), true)) { - throw new \InvalidArgumentException( - sprintf( - '%s needs to implement "%s".', - $this->addToNewStorageListClass, - AddToNewStorageListInterface::class - ), - ); - } - - return new $this->addToNewStorageListClass($storageListItem); - } -} diff --git a/src/CoreShop/Component/StorageList/Factory/AddToSelectableStorageListFactory.php b/src/CoreShop/Component/StorageList/Factory/AddToSelectableStorageListFactory.php deleted file mode 100644 index bf68ed24ff..0000000000 --- a/src/CoreShop/Component/StorageList/Factory/AddToSelectableStorageListFactory.php +++ /dev/null @@ -1,46 +0,0 @@ -addToWishlistClass), true)) { - throw new \InvalidArgumentException( - sprintf('%s needs to implement "%s".', $this->addToWishlistClass, AddToSelectableStorageListInterface::class), - ); - } - - return new $this->addToWishlistClass($storageListItem); - } -} diff --git a/src/CoreShop/Component/StorageList/Resolver/StorageListResolverInterface.php b/src/CoreShop/Component/StorageList/Resolver/StorageListResolverInterface.php index ccdb4b096c..28cfe65691 100644 --- a/src/CoreShop/Component/StorageList/Resolver/StorageListResolverInterface.php +++ b/src/CoreShop/Component/StorageList/Resolver/StorageListResolverInterface.php @@ -25,7 +25,7 @@ interface StorageListResolverInterface /** * @return StorageListInterface[] */ - public function getStorageLists(): array; + public function getStorageLists(array $context): array; - public function findNamed(string $name): ?StorageListInterface; + public function findNamed(array $context, string $name): ?StorageListInterface; } diff --git a/src/CoreShop/Component/StorageList/Storage/StorageListStorageInterface.php b/src/CoreShop/Component/StorageList/Storage/StorageListStorageInterface.php index b367618ee9..d8a237be9f 100644 --- a/src/CoreShop/Component/StorageList/Storage/StorageListStorageInterface.php +++ b/src/CoreShop/Component/StorageList/Storage/StorageListStorageInterface.php @@ -29,4 +29,6 @@ public function getForContext(array $context): ?StorageListInterface; public function setForContext(array $context, StorageListInterface $storageList): void; public function removeForContext(array $context): void; + + public function gotReset(): bool; }