Index.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Wishlist\Controller\Index;
  7. use Magento\Framework\App\Action;
  8. use Magento\Framework\Exception\NotFoundException;
  9. use Magento\Framework\Controller\ResultFactory;
  10. class Index extends \Magento\Wishlist\Controller\AbstractIndex
  11. {
  12. /**
  13. * @var \Magento\Wishlist\Controller\WishlistProviderInterface
  14. */
  15. protected $wishlistProvider;
  16. /**
  17. * @param Action\Context $context
  18. * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider
  19. */
  20. public function __construct(
  21. Action\Context $context,
  22. \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider
  23. ) {
  24. $this->wishlistProvider = $wishlistProvider;
  25. parent::__construct($context);
  26. }
  27. /**
  28. * Display customer wishlist
  29. *
  30. * @return \Magento\Framework\View\Result\Page
  31. * @throws NotFoundException
  32. */
  33. public function execute()
  34. {
  35. if (!$this->wishlistProvider->getWishlist()) {
  36. throw new NotFoundException(__('Page not found.'));
  37. }
  38. /** @var \Magento\Framework\View\Result\Page resultPage */
  39. $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
  40. return $resultPage;
  41. }
  42. }