1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Wishlist\Helper;
/**
* Wishlist rss helper
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*
* @api
* @since 100.0.2
*/
class Rss extends \Magento\Wishlist\Helper\Data
{
/**
* @var \Magento\Customer\Api\Data\CustomerInterface
*/
protected $_customer;
/**
* @var \Magento\Customer\Api\Data\CustomerInterfaceFactory
*/
protected $_customerFactory;
/**
* @var \Magento\Customer\Api\CustomerRepositoryInterface
*/
protected $_customerRepository;
/**
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Wishlist\Model\WishlistFactory $wishlistFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper
* @param \Magento\Customer\Helper\View $customerViewHelper
* @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
* @param \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Customer\Model\Session $customerSession,
\Magento\Wishlist\Model\WishlistFactory $wishlistFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
\Magento\Customer\Helper\View $customerViewHelper,
\Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider,
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
\Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
) {
$this->_customerFactory = $customerFactory;
$this->_customerRepository = $customerRepository;
parent::__construct(
$context,
$coreRegistry,
$customerSession,
$wishlistFactory,
$storeManager,
$postDataHelper,
$customerViewHelper,
$wishlistProvider,
$productRepository
);
}
/**
* Retrieve Wishlist model
*
* @return \Magento\Wishlist\Model\Wishlist
*/
public function getWishlist()
{
if ($this->_wishlist === null) {
$this->_wishlist = $this->_wishlistFactory->create();
$wishlistId = $this->_getRequest()->getParam('wishlist_id');
if ($wishlistId) {
$this->_wishlist->load($wishlistId);
} else {
if ($this->getCustomer()->getId()) {
$this->_wishlist->loadByCustomerId($this->getCustomer()->getId());
}
}
}
return $this->_wishlist;
}
/**
* Retrieve Customer instance
*
* @return \Magento\Customer\Api\Data\CustomerInterface
*/
public function getCustomer()
{
if ($this->_customer === null) {
$params = $this->urlDecoder->decode($this->_getRequest()->getParam('data'));
$data = explode(',', $params);
$customerId = abs((int)$data[0]);
if ($customerId && ($customerId == $this->_customerSession->getCustomerId())) {
$this->_customer = $this->_customerRepository->getById($customerId);
} else {
$this->_customer = $this->_customerFactory->create();
}
}
return $this->_customer;
}
/**
* Is allow RSS
*
* @return bool
*/
public function isRssAllow()
{
return $this->_moduleManager->isEnabled('Magento_Rss')
&& $this->scopeConfig->isSetFlag(
'rss/wishlist/active',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
}