_collectionFactory = $collectionFactory; parent::__construct( $context, $customerSession, $subscriberFactory, $customerRepository, $customerAccountManagement, $data ); $this->currentCustomer = $currentCustomer; } /** * Get html code for toolbar * * @return string */ public function getToolbarHtml() { return $this->getChildHtml('toolbar'); } /** * Initializes toolbar * * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _prepareLayout() { if ($this->getReviews()) { $toolbar = $this->getLayout()->createBlock( \Magento\Theme\Block\Html\Pager::class, 'customer_review_list.toolbar' )->setCollection( $this->getReviews() ); $this->setChild('toolbar', $toolbar); } return parent::_prepareLayout(); } /** * Get reviews * * @return bool|\Magento\Review\Model\ResourceModel\Review\Product\Collection */ public function getReviews() { if (!($customerId = $this->currentCustomer->getCustomerId())) { return false; } if (!$this->_collection) { $this->_collection = $this->_collectionFactory->create(); $this->_collection ->addStoreFilter($this->_storeManager->getStore()->getId()) ->addCustomerFilter($customerId) ->setDateOrder(); } return $this->_collection; } /** * Get review link * * @return string * @deprecated 100.2.0 */ public function getReviewLink() { return $this->getUrl('review/customer/view/'); } /** * Get review URL * * @param \Magento\Review\Model\Review $review * @return string * @since 100.2.0 */ public function getReviewUrl($review) { return $this->getUrl('review/customer/view', ['id' => $review->getReviewId()]); } /** * Get product link * * @return string * @deprecated 100.2.0 */ public function getProductLink() { return $this->getUrl('catalog/product/view/'); } /** * Get product URL * * @param \Magento\Catalog\Model\Product $product * @return string * @since 100.2.0 */ public function getProductUrl($product) { return $product->getProductUrl(); } /** * Format date in short format * * @param string $date * @return string */ public function dateFormat($date) { return $this->formatDate($date, \IntlDateFormatter::SHORT); } /** * Add review summary * * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _beforeToHtml() { $reviews = $this->getReviews(); if ($reviews) { $reviews->load()->addReviewSummary(); } return parent::_beforeToHtml(); } }