![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-wishlist/Controller/Shared/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Wishlist\Controller\Shared; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Controller\Result\Forward; use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Wishlist\Model\ItemCarrier; /** * Wishlist Allcart Controller */ class Allcart extends Action implements HttpPostActionInterface { /** * @var WishlistProvider */ protected $wishlistProvider; /** * @var ItemCarrier */ protected $itemCarrier; /** * @param Context $context * @param WishlistProvider $wishlistProvider * @param ItemCarrier $itemCarrier */ public function __construct( Context $context, WishlistProvider $wishlistProvider, ItemCarrier $itemCarrier ) { $this->wishlistProvider = $wishlistProvider; $this->itemCarrier = $itemCarrier; parent::__construct($context); } /** * Add all items from wishlist to shopping cart * * {@inheritDoc} */ public function execute() { $wishlist = $this->wishlistProvider->getWishlist(); if (!$wishlist) { /** @var Forward $resultForward */ $resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD); $resultForward->forward('noroute'); return $resultForward; } $redirectUrl = $this->itemCarrier->moveAllToCart($wishlist, $this->getRequest()->getParam('qty')); /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setUrl($redirectUrl); return $resultRedirect; } }