Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Delete.php
Go to the documentation of this file.
1 <?php
7 
10 
12 {
16  public function execute()
17  {
19  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
20  $reviewId = $this->getRequest()->getParam('id', false);
21  try {
22  $this->reviewFactory->create()->setId($reviewId)->aggregate()->delete();
23 
24  $this->messageManager->addSuccess(__('The review has been deleted.'));
25  if ($this->getRequest()->getParam('ret') == 'pending') {
26  $resultRedirect->setPath('review/*/pending');
27  } else {
28  $resultRedirect->setPath('review/*/');
29  }
30  return $resultRedirect;
31  } catch (\Magento\Framework\Exception\LocalizedException $e) {
32  $this->messageManager->addError($e->getMessage());
33  } catch (\Exception $e) {
34  $this->messageManager->addException($e, __('Something went wrong deleting this review.'));
35  }
36 
37  return $resultRedirect->setPath('review/*/edit/', ['id' => $reviewId]);
38  }
39 }
__()
Definition: __.php:13