Skip to content

Commit b7318ff

Browse files
author
Yuri Kovsher
committed
Merge remote-tracking branch 'tango-ce/MAGETWO-36732' into MAGETWO-34590
2 parents 4f12bca + b0b9775 commit b7318ff

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Sendfriend\Controller\Product;
87

8+
use Magento\Framework\Controller\ResultFactory;
9+
910
class Send extends \Magento\Sendfriend\Controller\Product
1011
{
1112
/**
1213
* Show Send to a Friend Form
1314
*
14-
* @return void
15+
* @return \Magento\Framework\Controller\ResultInterface
1516
*/
1617
public function execute()
1718
{
1819
$product = $this->_initProduct();
1920

2021
if (!$product) {
21-
$this->_forward('noroute');
22-
return;
22+
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
23+
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
24+
$resultForward->forward('noroute');
25+
return $resultForward;
2326
}
2427
/* @var $session \Magento\Catalog\Model\Session */
2528
$catalogSession = $this->_objectManager->get('Magento\Catalog\Model\Session');
@@ -30,19 +33,20 @@ public function execute()
3033
);
3134
}
3235

33-
$this->_view->loadLayout();
34-
$this->_view->getLayout()->initMessages();
36+
/** @var \Magento\Framework\View\Result\Page $resultPage */
37+
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
38+
$resultPage->getLayout()->initMessages();
3539

3640
$this->_eventManager->dispatch('sendfriend_product', ['product' => $product]);
3741
$data = $catalogSession->getSendfriendFormData();
3842
if ($data) {
3943
$catalogSession->setSendfriendFormData(true);
40-
$block = $this->_view->getLayout()->getBlock('sendfriend.send');
44+
$block = $resultPage->getLayout()->getBlock('sendfriend.send');
4145
if ($block) {
4246
$block->setFormData($data);
4347
}
4448
}
4549

46-
$this->_view->renderLayout();
50+
return $resultPage;
4751
}
4852
}

app/code/Magento/Sendfriend/Controller/Product/Sendmail.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
@@ -10,6 +9,7 @@
109
namespace Magento\Sendfriend\Controller\Product;
1110

1211
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Framework\Controller\ResultFactory;
1313

1414
class Sendmail extends \Magento\Sendfriend\Controller\Product
1515
{
@@ -39,22 +39,27 @@ public function __construct(
3939
/**
4040
* Send Email Post Action
4141
*
42-
* @return void
42+
* @return \Magento\Framework\Controller\ResultInterface
4343
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
4444
*/
4545
public function execute()
4646
{
47+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
48+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
49+
4750
if (!$this->_formKeyValidator->validate($this->getRequest())) {
48-
$this->_redirect('sendfriend/product/send', ['_current' => true]);
49-
return;
51+
$resultRedirect->setPath('sendfriend/product/send', ['_current' => true]);
52+
return $resultRedirect;
5053
}
5154

5255
$product = $this->_initProduct();
5356
$data = $this->getRequest()->getPostValue();
5457

5558
if (!$product || !$data) {
56-
$this->_forward('noroute');
57-
return;
59+
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
60+
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
61+
$resultForward->forward('noroute');
62+
return $resultForward;
5863
}
5964

6065
$categoryId = $this->getRequest()->getParam('cat_id', null);
@@ -82,8 +87,8 @@ public function execute()
8287
$this->sendFriend->send();
8388
$this->messageManager->addSuccess(__('The link to a friend was sent.'));
8489
$url = $product->getProductUrl();
85-
$this->getResponse()->setRedirect($this->_redirect->success($url));
86-
return;
90+
$resultRedirect->setUrl($this->_redirect->success($url));
91+
return $resultRedirect;
8792
} else {
8893
if (is_array($validate)) {
8994
foreach ($validate as $errorMessage) {
@@ -103,6 +108,7 @@ public function execute()
103108
$catalogSession->setSendfriendFormData($data);
104109

105110
$url = $this->_url->getUrl('sendfriend/product/send', ['_current' => true]);
106-
$this->getResponse()->setRedirect($this->_redirect->error($url));
111+
$resultRedirect->setUrl($this->_redirect->error($url));
112+
return $resultRedirect;
107113
}
108114
}

0 commit comments

Comments
 (0)