Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
View.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class View extends ProductController
13 {
21  protected function loadReview($reviewId)
22  {
23  if (!$reviewId) {
24  return false;
25  }
27  $review = $this->reviewFactory->create()->load($reviewId);
28  if (!$review->getId()
29  || !$review->isApproved()
30  || !$review->isAvailableOnStore($this->storeManager->getStore())
31  ) {
32  return false;
33  }
34  $this->coreRegistry->register('current_review', $review);
35  return $review;
36  }
37 
43  public function execute()
44  {
45  $review = $this->loadReview((int)$this->getRequest()->getParam('id'));
47  $resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
48  if (!$review) {
49  $resultForward->forward('noroute');
50  return $resultForward;
51  }
52 
53  $product = $this->loadProduct($review->getEntityPkValue());
54  if (!$product) {
55  $resultForward->forward('noroute');
56  return $resultForward;
57  }
59  $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
60  return $resultPage;
61  }
62 }