Skip to content

Commit bad2d47

Browse files
author
Natalia Momotenko
committed
Merge remote-tracking branch 'origin/develop' into WD
2 parents b2f5cfa + 237cbca commit bad2d47

File tree

92 files changed

+1641
-1404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1641
-1404
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/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77

88
use Magento\Backend\App\Action;
99
use Magento\Framework\Notification\NotifierInterface;
10+
use Magento\Framework\Controller\ResultFactory;
1011

1112
/**
1213
* GoogleShopping Admin Items Controller
13-
*
14-
* @name \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items
15-
* @author Magento Core Team <[email protected]>
1614
*/
1715
class Items extends \Magento\Backend\App\Action
1816
{
@@ -55,7 +53,7 @@ protected function _getFlag()
5553
* Redirect user to Google Captcha challenge
5654
*
5755
* @param \Zend_Gdata_App_CaptchaRequiredException $e
58-
* @return void
56+
* @return \Magento\Framework\Controller\ResultInterface
5957
*/
6058
protected function _redirectToCaptcha($e)
6159
{
@@ -68,12 +66,13 @@ protected function _redirectToCaptcha($e)
6866
]
6967
);
7068
if ($this->getRequest()->isAjax()) {
71-
$this->getResponse()->representJson(
72-
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')
73-
->jsonEncode(['redirect' => $redirectUrl])
74-
);
69+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
70+
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
71+
return $resultJson->setData(['redirect' => $redirectUrl]);
7572
} else {
76-
$this->_redirect($redirectUrl);
73+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
74+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
75+
return $resultRedirect->setUrl($redirectUrl);
7776
}
7877
}
7978

app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/ConfirmCaptcha.php

Lines changed: 13 additions & 19 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
*/
@@ -35,39 +34,34 @@ public function __construct(
3534
/**
3635
* Confirm CAPTCHA
3736
*
38-
* @return void
37+
* @return \Magento\Framework\Controller\ResultInterface
3938
*/
4039
public function execute()
4140
{
4241
$storeId = $this->_getStore()->getId();
4342
try {
44-
$this->_objectManager->create(
45-
'Magento\GoogleShopping\Model\Service'
46-
)->getClient(
47-
$storeId,
48-
$this->urlDecoder->decode(
49-
$this->getRequest()->getParam('captcha_token')
50-
),
51-
$this->getRequest()->getParam('user_confirm')
52-
);
43+
$this->_objectManager->create('Magento\GoogleShopping\Model\Service')
44+
->getClient(
45+
$storeId,
46+
$this->urlDecoder->decode($this->getRequest()->getParam('captcha_token')),
47+
$this->getRequest()->getParam('user_confirm')
48+
);
5349
$this->messageManager->addSuccess(__('Captcha has been confirmed.'));
5450
} catch (\Zend_Gdata_App_CaptchaRequiredException $e) {
5551
$this->messageManager->addError(__('There was a Captcha confirmation error: %1', $e->getMessage()));
56-
$this->_redirectToCaptcha($e);
57-
return;
52+
return $this->_redirectToCaptcha($e);
5853
} catch (\Zend_Gdata_App_Exception $e) {
5954
$this->messageManager->addError(
60-
$this->_objectManager->get(
61-
'Magento\GoogleShopping\Helper\Data'
62-
)->parseGdataExceptionMessage(
63-
$e->getMessage()
64-
)
55+
$this->_objectManager->get('Magento\GoogleShopping\Helper\Data')
56+
->parseGdataExceptionMessage($e->getMessage())
6557
);
6658
} catch (\Exception $e) {
6759
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
6860
$this->messageManager->addError(__('Something went wrong during Captcha confirmation.'));
6961
}
7062

71-
$this->_redirect('adminhtml/*/index', ['store' => $storeId]);
63+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
64+
$resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
65+
return $resultRedirect->setPath('adminhtml/*/index', ['store' => $storeId]);
7266
}
7367
}

app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Grid.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,43 @@
66
*/
77
namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items;
88

9+
use Magento\Backend\App\Action;
10+
use Magento\Framework\Notification\NotifierInterface;
11+
912
class Grid extends \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items
1013
{
14+
/**
15+
* @var \Magento\Framework\View\LayoutFactory
16+
*/
17+
protected $layoutFactory;
18+
19+
/**
20+
* @param Action\Context $context
21+
* @param NotifierInterface $notifier
22+
* @param \Magento\Framework\Url\EncoderInterface $urlEncoder
23+
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
24+
*/
25+
public function __construct(
26+
Action\Context $context,
27+
NotifierInterface $notifier,
28+
\Magento\Framework\Url\EncoderInterface $urlEncoder,
29+
\Magento\Framework\View\LayoutFactory $layoutFactory
30+
) {
31+
$this->layoutFactory = $layoutFactory;
32+
parent::__construct($context, $notifier, $urlEncoder);
33+
}
34+
1135
/**
1236
* Grid with Google Content items
1337
*
14-
* @return void
38+
* @return \Magento\Framework\Controller\Result\Raw
1539
*/
1640
public function execute()
1741
{
18-
$this->_view->loadLayout();
19-
$this->getResponse()->setBody(
20-
$this->_view->getLayout()->createBlock(
21-
'Magento\GoogleShopping\Block\Adminhtml\Items\Item'
22-
)->setIndex(
23-
$this->getRequest()->getParam('index')
24-
)->toHtml()
25-
);
42+
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
43+
$resultRaw = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
44+
/** @var \Magento\GoogleShopping\Block\Adminhtml\Items\Item $block */
45+
$block = $this->layoutFactory->create()->createBlock('Magento\GoogleShopping\Block\Adminhtml\Items\Item');
46+
return $resultRaw->setContents($block->setIndex($this->getRequest()->getParam('index'))->toHtml());
2647
}
2748
}

app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Index.php

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -35,54 +35,36 @@ public function __construct(
3535
$this->urlDecoder = $urlDecoder;
3636
}
3737

38-
/**
39-
* Initialize general settings for action
40-
*
41-
* @return $this
42-
*/
43-
protected function _initAction()
44-
{
45-
$this->_view->loadLayout();
46-
$this->_setActiveMenu(
47-
'Magento_GoogleShopping::catalog_googleshopping_items'
48-
)->_addBreadcrumb(
49-
__('Catalog'),
50-
__('Catalog')
51-
)->_addBreadcrumb(
52-
__('Google Content'),
53-
__('Google Content')
54-
);
55-
return $this;
56-
}
57-
5838
/**
5939
* Manage Items page with two item grids: Magento products and Google Content items
6040
*
61-
* @return void
41+
* @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
6242
*/
6343
public function execute()
6444
{
6545
if (0 === (int)$this->getRequest()->getParam('store')) {
66-
$this->_redirect(
46+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
47+
$resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
48+
return $resultRedirect->setPath(
6749
'adminhtml/*/',
6850
[
69-
'store' => $this->_objectManager->get(
70-
'Magento\Store\Model\StoreManagerInterface'
71-
)->getStore()->getId(),
51+
'store' => $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')
52+
->getStore()->getId(),
7253
'_current' => true
7354
]
7455
);
75-
return;
7656
}
7757

78-
$this->_initAction();
79-
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Google Content Items'));
58+
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
59+
$resultPage = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
60+
$resultPage->setActiveMenu('Magento_GoogleShopping::catalog_googleshopping_items')
61+
->addBreadcrumb(__('Catalog'), __('Catalog'))
62+
->addBreadcrumb(__('Google Content'), __('Google Content'));
63+
$resultPage->getConfig()->getTitle()->prepend(__('Google Content Items'));
8064

81-
$contentBlock = $this->_view->getLayout()->createBlock(
82-
'Magento\GoogleShopping\Block\Adminhtml\Items'
83-
)->setStore(
84-
$this->_getStore()
85-
);
65+
$contentBlock = $resultPage->getLayout()
66+
->createBlock('Magento\GoogleShopping\Block\Adminhtml\Items')
67+
->setStore($this->_getStore());
8668

8769
if ($this->getRequest()->getParam('captcha_token') && $this->getRequest()->getParam('captcha_url')) {
8870
$contentBlock->setGcontentCaptchaToken(
@@ -97,11 +79,8 @@ public function execute()
9779
);
9880
}
9981

100-
if (!$this->_objectManager->get(
101-
'Magento\GoogleShopping\Model\Config'
102-
)->isValidDefaultCurrencyCode(
103-
$this->_getStore()->getId()
104-
)
82+
if (!$this->_objectManager->get('Magento\GoogleShopping\Model\Config')
83+
->isValidDefaultCurrencyCode($this->_getStore()->getId())
10584
) {
10685
$_countryInfo = $this->_objectManager->get(
10786
'Magento\GoogleShopping\Model\Config'
@@ -110,14 +89,14 @@ public function execute()
11089
);
11190
$this->messageManager->addNotice(
11291
__(
113-
"The store's currency should be set to %1 for %2 in system configuration. Otherwise item prices won't be correct in Google Content.",
92+
"The store's currency should be set to %1 for %2 in system configuration."
93+
. " Otherwise item prices won't be correct in Google Content.",
11494
$_countryInfo['currency_name'],
11595
$_countryInfo['name']
11696
)
11797
);
11898
}
11999

120-
$this->_addBreadcrumb(__('Items'), __('Items'))->_addContent($contentBlock);
121-
$this->_view->renderLayout();
100+
return $resultPage->addBreadcrumb(__('Items'), __('Items'))->addContent($contentBlock);
122101
}
123102
}
Lines changed: 9 additions & 14 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,13 +10,14 @@ class MassAdd extends \Magento\GoogleShopping\Controller\Adminhtml\Googleshoppin
1110
/**
1211
* Add (export) several products to Google Content
1312
*
14-
* @return void
13+
* @return \Magento\Framework\Controller\ResultInterface
14+
* @throws \Magento\Framework\Exception\LocalizedException
1515
*/
1616
public function execute()
1717
{
1818
$flag = $this->_getFlag();
1919
if ($flag->isLocked()) {
20-
return;
20+
return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
2121
}
2222

2323
session_write_close();
@@ -29,30 +29,25 @@ public function execute()
2929

3030
try {
3131
$flag->lock();
32-
$this->_objectManager->create(
33-
'Magento\GoogleShopping\Model\MassOperations'
34-
)->setFlag(
35-
$flag
36-
)->addProducts(
37-
$productIds,
38-
$storeId
39-
);
32+
$this->_objectManager->create('Magento\GoogleShopping\Model\MassOperations')
33+
->setFlag($flag)
34+
->addProducts($productIds, $storeId);
4035
} catch (\Zend_Gdata_App_CaptchaRequiredException $e) {
4136
// Google requires CAPTCHA for login
4237
$this->messageManager->addError(__($e->getMessage()));
4338
$flag->unlock();
44-
$this->_redirectToCaptcha($e);
45-
return;
39+
return $this->_redirectToCaptcha($e);
4640
} catch (\Exception $e) {
4741
$flag->unlock();
4842
$this->notifier->addMajor(
4943
__('An error has occurred while adding products to google shopping account.'),
5044
$e->getMessage()
5145
);
5246
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
53-
return;
47+
return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
5448
}
5549

5650
$flag->unlock();
51+
return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
5752
}
5853
}

0 commit comments

Comments
 (0)