WishlistSettings.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Wishlist\Plugin\Ui\DataProvider;
  7. use Magento\Wishlist\Helper\Data;
  8. /**
  9. * Plugin on Data Provider for frontend ui components (Components are responsible
  10. * for rendering product on front)
  11. * This plugin provides allowWishlist setting
  12. */
  13. class WishlistSettings
  14. {
  15. /**
  16. * @var Data
  17. */
  18. private $helper;
  19. /**
  20. * WishlistSettings constructor.
  21. * @param Data $helper
  22. */
  23. public function __construct(Data $helper)
  24. {
  25. $this->helper = $helper;
  26. }
  27. /**
  28. * Add tax data to result
  29. *
  30. * @param \Magento\Catalog\Ui\DataProvider\Product\Listing\DataProvider $subject
  31. * @param array $result
  32. * @return array
  33. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  34. */
  35. public function afterGetData(\Magento\Catalog\Ui\DataProvider\Product\Listing\DataProvider $subject, $result)
  36. {
  37. $result['allowWishlist'] = $this->helper->isAllow();
  38. return $result;
  39. }
  40. }