Skip to content

Commit 223f45d

Browse files
author
Yuri Kovsher
committed
Merge remote-tracking branch 'tango-ce/MAGETWO-36101' into MAGETWO-36610
2 parents a3509e1 + fc64def commit 223f45d

File tree

26 files changed

+599
-529
lines changed

26 files changed

+599
-529
lines changed

app/code/Magento/Backend/App/Action/Context.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Backend\App\Action;
77

8+
use Magento\Framework\Controller\ResultFactory;
9+
810
/**
911
* Backend Controller context
1012
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -62,6 +64,7 @@ class Context extends \Magento\Framework\App\Action\Context
6264
* @param \Magento\Framework\App\ViewInterface $view
6365
* @param \Magento\Framework\Message\ManagerInterface $messageManager
6466
* @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
67+
* @param \Magento\Framework\Controller\ResultFactory $resultFactory
6568
* @param \Magento\Backend\Model\Session $session
6669
* @param \Magento\Framework\AuthorizationInterface $authorization
6770
* @param \Magento\Backend\Model\Auth $auth
@@ -83,6 +86,7 @@ public function __construct(
8386
\Magento\Framework\App\ViewInterface $view,
8487
\Magento\Framework\Message\ManagerInterface $messageManager,
8588
\Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
89+
ResultFactory $resultFactory,
8690
\Magento\Backend\Model\Session $session,
8791
\Magento\Framework\AuthorizationInterface $authorization,
8892
\Magento\Backend\Model\Auth $auth,
@@ -102,7 +106,8 @@ public function __construct(
102106
$actionFlag,
103107
$view,
104108
$messageManager,
105-
$resultRedirectFactory
109+
$resultRedirectFactory,
110+
$resultFactory
106111
);
107112

108113
$this->_session = $session;

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@
9090
<argument name="instanceName" xsi:type="string">Magento\Backend\Model\View\Result\Page</argument>
9191
</arguments>
9292
</type>
93+
<type name="Magento\Framework\Controller\ResultFactory">
94+
<arguments>
95+
<argument name="typeMap" xsi:type="array">
96+
<item name="redirect" xsi:type="array">
97+
<item name="type" xsi:type="const">Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT</item>
98+
<item name="class" xsi:type="string">Magento\Backend\Model\View\Result\Redirect</item>
99+
</item>
100+
<item name="page" xsi:type="array">
101+
<item name="type" xsi:type="const">Magento\Framework\Controller\ResultFactory::TYPE_PAGE</item>
102+
<item name="class" xsi:type="string">Magento\Backend\Model\View\Result\Page</item>
103+
</item>
104+
<item name="forward" xsi:type="array">
105+
<item name="type" xsi:type="const">Magento\Framework\Controller\ResultFactory::TYPE_FORWARD</item>
106+
<item name="class" xsi:type="string">Magento\Backend\Model\View\Result\Forward</item>
107+
</item>
108+
</argument>
109+
</arguments>
110+
</type>
93111
<type name="Magento\Framework\View\Layout\BuilderFactory">
94112
<arguments>
95113
<argument name="typeMap" xsi:type="array">

app/code/Magento/Wishlist/Controller/Index/Add.php

Lines changed: 11 additions & 11 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
*/
@@ -11,6 +10,7 @@
1110
use Magento\Framework\Exception\NotFoundException;
1211
use Magento\Framework\Exception\NoSuchEntityException;
1312
use Magento\Wishlist\Controller\IndexInterface;
13+
use Magento\Framework\Controller\ResultFactory;
1414

1515
class Add extends Action\Action implements IndexInterface
1616
{
@@ -50,7 +50,7 @@ public function __construct(
5050
/**
5151
* Adding new item
5252
*
53-
* @return void
53+
* @return \Magento\Framework\Controller\Result\Redirect
5454
* @throws NotFoundException
5555
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5656
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -73,10 +73,11 @@ public function execute()
7373
}
7474

7575
$productId = isset($requestParams['product']) ? (int)$requestParams['product'] : null;
76-
76+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
77+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
7778
if (!$productId) {
78-
$this->_redirect('*/');
79-
return;
79+
$resultRedirect->setPath('*/');
80+
return $resultRedirect;
8081
}
8182

8283
try {
@@ -87,8 +88,8 @@ public function execute()
8788

8889
if (!$product || !$product->isVisibleInCatalog()) {
8990
$this->messageManager->addError(__('We can\'t specify a product.'));
90-
$this->_redirect('*/');
91-
return;
91+
$resultRedirect->setPath('*/');
92+
return $resultRedirect;
9293
}
9394

9495
try {
@@ -112,9 +113,7 @@ public function execute()
112113
$referer = $this->_redirect->getRefererUrl();
113114
}
114115

115-
116-
/** @var $helper \Magento\Wishlist\Helper\Data */
117-
$helper = $this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate();
116+
$this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate();
118117
$message = __(
119118
'%1 has been added to your wishlist. Click <a href="%2">here</a> to continue shopping.',
120119
$this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($product->getName()),
@@ -130,6 +129,7 @@ public function execute()
130129
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
131130
}
132131

133-
$this->_redirect('*', ['wishlist_id' => $wishlist->getId()]);
132+
$resultRedirect->setPath('*', ['wishlist_id' => $wishlist->getId()]);
133+
return $resultRedirect;
134134
}
135135
}

app/code/Magento/Wishlist/Controller/Index/Allcart.php

Lines changed: 12 additions & 7 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
*/
@@ -12,6 +11,7 @@
1211
use Magento\Wishlist\Controller\IndexInterface;
1312
use Magento\Wishlist\Controller\WishlistProviderInterface;
1413
use Magento\Wishlist\Model\ItemCarrier;
14+
use Magento\Framework\Controller\ResultFactory;
1515

1616
class Allcart extends Action\Action implements IndexInterface
1717
{
@@ -51,21 +51,26 @@ public function __construct(
5151
/**
5252
* Add all items from wishlist to shopping cart
5353
*
54-
* @return void
54+
* @return \Magento\Framework\Controller\ResultInterface
5555
*/
5656
public function execute()
5757
{
58+
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
59+
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
5860
if (!$this->formKeyValidator->validate($this->getRequest())) {
59-
$this->_forward('noroute');
60-
return;
61+
$resultForward->forward('noroute');
62+
return $resultForward;
6163
}
6264

6365
$wishlist = $this->wishlistProvider->getWishlist();
6466
if (!$wishlist) {
65-
$this->_forward('noroute');
66-
return;
67+
$resultForward->forward('noroute');
68+
return $resultForward;
6769
}
70+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
71+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
6872
$redirectUrl = $this->itemCarrier->moveAllToCart($wishlist, $this->getRequest()->getParam('qty'));
69-
$this->getResponse()->setRedirect($redirectUrl);
73+
$resultRedirect->setUrl($redirectUrl);
74+
return $resultRedirect;
7075
}
7176
}

app/code/Magento/Wishlist/Controller/Index/Cart.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Wishlist\Controller\Index;
87

98
use Magento\Framework\App\Action;
10-
use Magento\Framework\App\ResponseInterface;
119
use Magento\Wishlist\Controller\IndexInterface;
1210
use Magento\Catalog\Model\Product\Exception as ProductException;
11+
use Magento\Framework\Controller\ResultFactory;
1312

1413
/**
1514
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -95,22 +94,25 @@ public function __construct(
9594
* If Product has required options - item removed from wishlist and redirect
9695
* to product view page with message about needed defined required options
9796
*
98-
* @return ResponseInterface
97+
* @return \Magento\Framework\Controller\Result\Redirect
9998
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
10099
* @SuppressWarnings(PHPMD.NPathComplexity)
101100
*/
102101
public function execute()
103102
{
104103
$itemId = (int)$this->getRequest()->getParam('item');
105-
104+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
105+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
106106
/* @var $item \Magento\Wishlist\Model\Item */
107107
$item = $this->itemFactory->create()->load($itemId);
108108
if (!$item->getId()) {
109-
return $this->_redirect('*/*');
109+
$resultRedirect->setPath('*/*');
110+
return $resultRedirect;
110111
}
111112
$wishlist = $this->wishlistProvider->getWishlist($item->getWishlistId());
112113
if (!$wishlist) {
113-
return $this->_redirect('*/*');
114+
$resultRedirect->setPath('*/*');
115+
return $resultRedirect;
114116
}
115117

116118
// Set qty
@@ -177,7 +179,7 @@ public function execute()
177179
}
178180

179181
$this->helper->calculate();
180-
181-
return $this->getResponse()->setRedirect($redirectUrl);
182+
$resultRedirect->setUrl($redirectUrl);
183+
return $resultRedirect;
182184
}
183185
}

app/code/Magento/Wishlist/Controller/Index/Configure.php

Lines changed: 9 additions & 7 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
*/
@@ -9,6 +8,7 @@
98
use Magento\Framework\App\Action;
109
use Magento\Framework\Exception\NotFoundException;
1110
use Magento\Wishlist\Controller\IndexInterface;
11+
use Magento\Framework\Controller\ResultFactory;
1212

1313
class Configure extends Action\Action implements IndexInterface
1414
{
@@ -50,12 +50,14 @@ public function __construct(
5050
/**
5151
* Action to reconfigure wishlist item
5252
*
53-
* @return void
53+
* @return \Magento\Framework\Controller\ResultInterface
5454
* @throws NotFoundException
5555
*/
5656
public function execute()
5757
{
5858
$id = (int)$this->getRequest()->getParam('id');
59+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
60+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
5961
try {
6062
/* @var $item \Magento\Wishlist\Model\Item */
6163
$item = $this->_objectManager->create('Magento\Wishlist\Model\Item');
@@ -83,7 +85,7 @@ public function execute()
8385
}
8486
$params->setBuyRequest($buyRequest);
8587
/** @var \Magento\Framework\View\Result\Page $resultPage */
86-
$resultPage = $this->resultPageFactory->create();
88+
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
8789
$this->_objectManager->get(
8890
'Magento\Catalog\Helper\Product\View'
8991
)->prepareAndRender(
@@ -96,13 +98,13 @@ public function execute()
9698
return $resultPage;
9799
} catch (\Magento\Framework\Exception\LocalizedException $e) {
98100
$this->messageManager->addError($e->getMessage());
99-
$this->_redirect('*');
100-
return;
101+
$resultRedirect->setPath('*');
102+
return $resultRedirect;
101103
} catch (\Exception $e) {
102104
$this->messageManager->addError(__('We can\'t configure the product.'));
103105
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
104-
$this->_redirect('*');
105-
return;
106+
$resultRedirect->setPath('*');
107+
return $resultRedirect;
106108
}
107109
}
108110
}

app/code/Magento/Wishlist/Controller/Index/DownloadCustomOption.php

Lines changed: 12 additions & 8 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
*/
@@ -9,6 +8,7 @@
98
use Magento\Framework\App\Action;
109
use Magento\Framework\App\Filesystem\DirectoryList;
1110
use Magento\Wishlist\Controller\IndexInterface;
11+
use Magento\Framework\Controller\ResultFactory;
1212

1313
class DownloadCustomOption extends Action\Action implements IndexInterface
1414
{
@@ -32,7 +32,7 @@ public function __construct(
3232
/**
3333
* Custom options download action
3434
*
35-
* @return void
35+
* @return \Magento\Framework\Controller\Result\Forward
3636
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
3737
* @SuppressWarnings(PHPMD.ExitExpression)
3838
*/
@@ -43,9 +43,11 @@ public function execute()
4343
)->load(
4444
$this->getRequest()->getParam('id')
4545
);
46-
46+
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
47+
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
4748
if (!$option->getId()) {
48-
return $this->_forward('noroute');
49+
$resultForward->forward('noroute');
50+
return $resultForward;
4951
}
5052

5153
$optionId = null;
@@ -56,7 +58,8 @@ public function execute()
5658
$option->getCode()
5759
);
5860
if ((int)$optionId != $optionId) {
59-
return $this->_forward('noroute');
61+
$resultForward->forward('noroute');
62+
return $resultForward;
6063
}
6164
}
6265
$productOption = $this->_objectManager->create('Magento\Catalog\Model\Product\Option')->load($optionId);
@@ -66,7 +69,8 @@ public function execute()
6669
$productOption->getProductId() != $option->getProductId() ||
6770
$productOption->getType() != 'file'
6871
) {
69-
return $this->_forward('noroute');
72+
$resultForward->forward('noroute');
73+
return $resultForward;
7074
}
7175

7276
try {
@@ -81,8 +85,8 @@ public function execute()
8185
);
8286
}
8387
} catch (\Exception $e) {
84-
$this->_forward('noroute');
88+
$resultForward->forward('noroute');
89+
return $resultForward;
8590
}
86-
exit(0);
8791
}
8892
}

app/code/Magento/Wishlist/Controller/Index/Fromcart.php

Lines changed: 3 additions & 2 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
*/
@@ -9,6 +8,7 @@
98
use Magento\Framework\App\Action;
109
use Magento\Framework\Exception\NotFoundException;
1110
use Magento\Wishlist\Controller\IndexInterface;
11+
use Magento\Framework\Controller\ResultFactory;
1212

1313
class Fromcart extends Action\Action implements IndexInterface
1414
{
@@ -82,7 +82,8 @@ public function execute()
8282
*/
8383
public function getDefaultResult()
8484
{
85-
$resultRedirect = $this->resultRedirectFactory->create();
85+
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
86+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
8687
return $resultRedirect->setUrl($this->_objectManager->get('Magento\Checkout\Helper\Cart')->getCartUrl());
8788
}
8889
}

0 commit comments

Comments
 (0)