diff --git a/app/code/Magento/Wishlist/Controller/Shared/Allcart.php b/app/code/Magento/Wishlist/Controller/Shared/Allcart.php index 6300b14dcf515..8d160d270a6f0 100644 --- a/app/code/Magento/Wishlist/Controller/Shared/Allcart.php +++ b/app/code/Magento/Wishlist/Controller/Shared/Allcart.php @@ -3,55 +3,68 @@ * 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\Context; -use Magento\Wishlist\Model\ItemCarrier; +use Magento\Framework\App\Action\HttpGetActionInterface; +use Magento\Framework\App\RequestInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\Result\Forward; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Wishlist\Model\ItemCarrier; -class Allcart extends \Magento\Framework\App\Action\Action +class Allcart implements HttpGetActionInterface { + /** + * @var ItemCarrier + */ + private $itemCarrier; + /** * @var WishlistProvider */ - protected $wishlistProvider; + private $wishlistProvider; /** - * @var \Magento\Wishlist\Model\ItemCarrier + * @var RequestInterface */ - protected $itemCarrier; + private $request; /** - * @param Context $context - * @param WishlistProvider $wishlistProvider - * @param ItemCarrier $itemCarrier + * @var ResultFactory */ + private $resultFactory; + public function __construct( - Context $context, - WishlistProvider $wishlistProvider, - ItemCarrier $itemCarrier + ItemCarrier $itemCarrier, + RequestInterface $request, + ResultFactory $resultFactory, + WishlistProvider $wishlistProvider ) { - $this->wishlistProvider = $wishlistProvider; $this->itemCarrier = $itemCarrier; - parent::__construct($context); + $this->request = $request; + $this->resultFactory = $resultFactory; + $this->wishlistProvider = $wishlistProvider; } /** * Add all items from wishlist to shopping cart * - * @return \Magento\Framework\Controller\ResultInterface + * @inheritDoc */ public function execute() { $wishlist = $this->wishlistProvider->getWishlist(); if (!$wishlist) { - /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ + /** @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 \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + $redirectUrl = $this->itemCarrier->moveAllToCart($wishlist, $this->request->getParam('qty')); + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setUrl($redirectUrl); return $resultRedirect;