Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Rss.php
Go to the documentation of this file.
1 <?php
8 
16 {
20  protected $_customer;
21 
25  protected $_customerFactory;
26 
31 
46  public function __construct(
47  \Magento\Framework\App\Helper\Context $context,
48  \Magento\Framework\Registry $coreRegistry,
49  \Magento\Customer\Model\Session $customerSession,
50  \Magento\Wishlist\Model\WishlistFactory $wishlistFactory,
51  \Magento\Store\Model\StoreManagerInterface $storeManager,
52  \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
53  \Magento\Customer\Helper\View $customerViewHelper,
55  \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
56  \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory,
57  \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
58  ) {
59  $this->_customerFactory = $customerFactory;
60  $this->_customerRepository = $customerRepository;
61 
62  parent::__construct(
63  $context,
64  $coreRegistry,
65  $customerSession,
66  $wishlistFactory,
68  $postDataHelper,
69  $customerViewHelper,
72  );
73  }
74 
80  public function getWishlist()
81  {
82  if ($this->_wishlist === null) {
83  $this->_wishlist = $this->_wishlistFactory->create();
84 
85  $wishlistId = $this->_getRequest()->getParam('wishlist_id');
86  if ($wishlistId) {
87  $this->_wishlist->load($wishlistId);
88  } else {
89  if ($this->getCustomer()->getId()) {
90  $this->_wishlist->loadByCustomerId($this->getCustomer()->getId());
91  }
92  }
93  }
94  return $this->_wishlist;
95  }
96 
102  public function getCustomer()
103  {
104  if ($this->_customer === null) {
105  $params = $this->urlDecoder->decode($this->_getRequest()->getParam('data'));
106  $data = explode(',', $params);
107  $customerId = abs(intval($data[0]));
108  if ($customerId && ($customerId == $this->_customerSession->getCustomerId())) {
109  $this->_customer = $this->_customerRepository->getById($customerId);
110  } else {
111  $this->_customer = $this->_customerFactory->create();
112  }
113  }
114 
115  return $this->_customer;
116  }
117 
123  public function isRssAllow()
124  {
125  return $this->_moduleManager->isEnabled('Magento_Rss')
126  && $this->scopeConfig->isSetFlag(
127  'rss/wishlist/active',
128  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
129  );
130  }
131 }
$storeManager
__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)
Definition: Rss.php:46
$customerRepository
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18