Skip to content

Commit 8b73294

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-37969' into sprint-54-bf
2 parents 86646fc + e1e6bf9 commit 8b73294

File tree

54 files changed

+789
-1053
lines changed

Some content is hidden

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

54 files changed

+789
-1053
lines changed

app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,29 @@
77
namespace Magento\Backend\Controller\Adminhtml\Cache;
88

99
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Controller\ResultFactory;
1011

1112
class CleanImages extends \Magento\Backend\Controller\Adminhtml\Cache
1213
{
1314
/**
1415
* Clean JS/css files cache
1516
*
1617
* @return \Magento\Backend\Model\View\Result\Redirect
17-
* @throws LocalizedException
1818
*/
1919
public function execute()
2020
{
21-
$this->_objectManager->create('Magento\Catalog\Model\Product\Image')->clearCache();
22-
$this->_eventManager->dispatch('clean_catalog_images_cache_after');
23-
$this->messageManager->addSuccess(__('The image cache was cleaned.'));
21+
try {
22+
$this->_objectManager->create('Magento\Catalog\Model\Product\Image')->clearCache();
23+
$this->_eventManager->dispatch('clean_catalog_images_cache_after');
24+
$this->messageManager->addSuccess(__('The image cache was cleaned.'));
25+
} catch (LocalizedException $e) {
26+
$this->messageManager->addError($e->getMessage());
27+
} catch (\Exception $e) {
28+
$this->messageManager->addException($e, __('An error occurred while clearing the image cache.'));
29+
}
2430

25-
return $this->getDefaultResult();
26-
}
27-
28-
/**
29-
* {@inheritdoc}
30-
*
31-
* @return \Magento\Backend\Model\View\Result\Redirect
32-
*/
33-
public function getDefaultResult()
34-
{
35-
$resultRedirect = $this->resultRedirectFactory->create();
31+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
32+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
3633
return $resultRedirect->setPath('adminhtml/*');
3734
}
3835
}

app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,29 @@
77
namespace Magento\Backend\Controller\Adminhtml\Cache;
88

99
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Controller\ResultFactory;
1011

1112
class CleanMedia extends \Magento\Backend\Controller\Adminhtml\Cache
1213
{
1314
/**
1415
* Clean JS/css files cache
1516
*
1617
* @return \Magento\Backend\Model\View\Result\Redirect
17-
* @throws LocalizedException
1818
*/
1919
public function execute()
2020
{
21-
$this->_objectManager->get('Magento\Framework\View\Asset\MergeService')->cleanMergedJsCss();
22-
$this->_eventManager->dispatch('clean_media_cache_after');
23-
$this->messageManager->addSuccess(__('The JavaScript/CSS cache has been cleaned.'));
21+
try {
22+
$this->_objectManager->get('Magento\Framework\View\Asset\MergeService')->cleanMergedJsCss();
23+
$this->_eventManager->dispatch('clean_media_cache_after');
24+
$this->messageManager->addSuccess(__('The JavaScript/CSS cache has been cleaned.'));
25+
} catch (LocalizedException $e) {
26+
$this->messageManager->addError($e->getMessage());
27+
} catch (\Exception $e) {
28+
$this->messageManager->addException($e, __('An error occurred while clearing the JavaScript/CSS cache.'));
29+
}
2430

25-
return $this->getDefaultResult();
26-
}
27-
28-
/**
29-
* {@inheritdoc}
30-
*
31-
* @return \Magento\Backend\Model\View\Result\Redirect
32-
*/
33-
public function getDefaultResult()
34-
{
35-
$resultRedirect = $this->resultRedirectFactory->create();
31+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
32+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
3633
return $resultRedirect->setPath('adminhtml/*');
3734
}
3835
}

app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,43 @@
77
namespace Magento\Backend\Controller\Adminhtml\Cache;
88

99
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Controller\ResultFactory;
1011

1112
class MassDisable extends \Magento\Backend\Controller\Adminhtml\Cache
1213
{
1314
/**
1415
* Mass action for cache disabling
1516
*
1617
* @return \Magento\Backend\Model\View\Result\Redirect
17-
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
1818
*/
1919
public function execute()
2020
{
21-
$types = $this->getRequest()->getParam('types');
22-
$updatedTypes = 0;
23-
if (!is_array($types)) {
24-
$types = [];
25-
}
26-
$this->_validateTypes($types);
27-
foreach ($types as $code) {
28-
if ($this->_cacheState->isEnabled($code)) {
29-
$this->_cacheState->setEnabled($code, false);
30-
$updatedTypes++;
21+
try {
22+
$types = $this->getRequest()->getParam('types');
23+
$updatedTypes = 0;
24+
if (!is_array($types)) {
25+
$types = [];
3126
}
32-
$this->_cacheTypeList->cleanType($code);
33-
}
34-
if ($updatedTypes > 0) {
35-
$this->_cacheState->persist();
36-
$this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes));
27+
$this->_validateTypes($types);
28+
foreach ($types as $code) {
29+
if ($this->_cacheState->isEnabled($code)) {
30+
$this->_cacheState->setEnabled($code, false);
31+
$updatedTypes++;
32+
}
33+
$this->_cacheTypeList->cleanType($code);
34+
}
35+
if ($updatedTypes > 0) {
36+
$this->_cacheState->persist();
37+
$this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes));
38+
}
39+
} catch (LocalizedException $e) {
40+
$this->messageManager->addError($e->getMessage());
41+
} catch (\Exception $e) {
42+
$this->messageManager->addException($e, __('An error occurred while disabling cache.'));
3743
}
3844

39-
return $this->getDefaultResult();
40-
}
41-
42-
/**
43-
* {@inheritdoc}
44-
*
45-
* @return \Magento\Backend\Model\View\Result\Redirect
46-
*/
47-
public function getDefaultResult()
48-
{
49-
$resultRedirect = $this->resultRedirectFactory->create();
45+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
46+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
5047
return $resultRedirect->setPath('adminhtml/*');
5148
}
5249
}

app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,42 @@
77
namespace Magento\Backend\Controller\Adminhtml\Cache;
88

99
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Controller\ResultFactory;
1011

1112
class MassEnable extends \Magento\Backend\Controller\Adminhtml\Cache
1213
{
1314
/**
1415
* Mass action for cache enabling
1516
*
1617
* @return \Magento\Backend\Model\View\Result\Redirect
17-
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
1818
*/
1919
public function execute()
2020
{
21-
$types = $this->getRequest()->getParam('types');
22-
$updatedTypes = 0;
23-
if (!is_array($types)) {
24-
$types = [];
25-
}
26-
$this->_validateTypes($types);
27-
foreach ($types as $code) {
28-
if (!$this->_cacheState->isEnabled($code)) {
29-
$this->_cacheState->setEnabled($code, true);
30-
$updatedTypes++;
21+
try {
22+
$types = $this->getRequest()->getParam('types');
23+
$updatedTypes = 0;
24+
if (!is_array($types)) {
25+
$types = [];
3126
}
27+
$this->_validateTypes($types);
28+
foreach ($types as $code) {
29+
if (!$this->_cacheState->isEnabled($code)) {
30+
$this->_cacheState->setEnabled($code, true);
31+
$updatedTypes++;
32+
}
33+
}
34+
if ($updatedTypes > 0) {
35+
$this->_cacheState->persist();
36+
$this->messageManager->addSuccess(__("%1 cache type(s) enabled.", $updatedTypes));
37+
}
38+
} catch (LocalizedException $e) {
39+
$this->messageManager->addError($e->getMessage());
40+
} catch (\Exception $e) {
41+
$this->messageManager->addException($e, __('An error occurred while enabling cache.'));
3242
}
33-
if ($updatedTypes > 0) {
34-
$this->_cacheState->persist();
35-
$this->messageManager->addSuccess(__("%1 cache type(s) enabled.", $updatedTypes));
36-
}
37-
38-
return $this->getDefaultResult();
39-
}
4043

41-
/**
42-
* {@inheritdoc}
43-
*
44-
* @return \Magento\Backend\Model\View\Result\Redirect
45-
*/
46-
public function getDefaultResult()
47-
{
48-
$resultRedirect = $this->resultRedirectFactory->create();
44+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
45+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
4946
return $resultRedirect->setPath('adminhtml/*');
5047
}
5148
}

app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,41 @@
66
*/
77
namespace Magento\Backend\Controller\Adminhtml\Cache;
88

9+
use Magento\Framework\Exception\LocalizedException;
10+
use Magento\Framework\Controller\ResultFactory;
11+
912
class MassRefresh extends \Magento\Backend\Controller\Adminhtml\Cache
1013
{
1114
/**
1215
* Mass action for cache refresh
1316
*
1417
* @return \Magento\Backend\Model\View\Result\Redirect
15-
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
1618
*/
1719
public function execute()
1820
{
19-
$types = $this->getRequest()->getParam('types');
20-
$updatedTypes = 0;
21-
if (!is_array($types)) {
22-
$types = [];
23-
}
24-
$this->_validateTypes($types);
25-
foreach ($types as $type) {
26-
$this->_cacheTypeList->cleanType($type);
27-
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => $type]);
28-
$updatedTypes++;
29-
}
30-
if ($updatedTypes > 0) {
31-
$this->messageManager->addSuccess(__("%1 cache type(s) refreshed.", $updatedTypes));
21+
try {
22+
$types = $this->getRequest()->getParam('types');
23+
$updatedTypes = 0;
24+
if (!is_array($types)) {
25+
$types = [];
26+
}
27+
$this->_validateTypes($types);
28+
foreach ($types as $type) {
29+
$this->_cacheTypeList->cleanType($type);
30+
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => $type]);
31+
$updatedTypes++;
32+
}
33+
if ($updatedTypes > 0) {
34+
$this->messageManager->addSuccess(__("%1 cache type(s) refreshed.", $updatedTypes));
35+
}
36+
} catch (LocalizedException $e) {
37+
$this->messageManager->addError($e->getMessage());
38+
} catch (\Exception $e) {
39+
$this->messageManager->addException($e, __('An error occurred while refreshing cache.'));
3240
}
3341

34-
return $this->getDefaultResult();
35-
}
36-
37-
/**
38-
* {@inheritdoc}
39-
*
40-
* @return \Magento\Backend\Model\View\Result\Redirect
41-
*/
42-
public function getDefaultResult()
43-
{
44-
$resultRedirect = $this->resultRedirectFactory->create();
42+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
43+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
4544
return $resultRedirect->setPath('adminhtml/*');
4645
}
4746
}

app/code/Magento/Backend/Controller/Adminhtml/Dashboard/RefreshStatistics.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,21 @@ public function __construct(
2626

2727
/**
2828
* @return \Magento\Backend\Model\View\Result\Redirect
29-
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
3029
*/
3130
public function execute()
3231
{
33-
$collectionsNames = array_values($this->reportTypes);
34-
foreach ($collectionsNames as $collectionName) {
35-
$this->_objectManager->create($collectionName)->aggregate();
32+
try {
33+
$collectionsNames = array_values($this->reportTypes);
34+
foreach ($collectionsNames as $collectionName) {
35+
$this->_objectManager->create($collectionName)->aggregate();
36+
}
37+
$this->messageManager->addSuccess(__('We updated lifetime statistic.'));
38+
} catch (\Exception $e) {
39+
$this->messageManager->addError(__('We can\'t refresh lifetime statistics.'));
40+
$this->logger->critical($e);
3641
}
37-
$this->messageManager->addSuccess(__('We updated lifetime statistic.'));
3842

39-
return $this->getDefaultResult();
40-
}
41-
42-
/**
43-
* {@inheritdoc}
44-
*
45-
* @return \Magento\Backend\Model\View\Result\Redirect
46-
*/
47-
public function getDefaultResult()
48-
{
43+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
4944
$resultRedirect = $this->resultRedirectFactory->create();
5045
return $resultRedirect->setPath('*/*');
5146
}

app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
*/
66
namespace Magento\Backend\Controller\Adminhtml\System\Account;
77

8+
use Magento\Framework\Validator\Exception as ValidatorException;
89
use Magento\Framework\Exception\AuthenticationException;
910
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\Controller\ResultFactory;
1012

1113
class Save extends \Magento\Backend\Controller\Adminhtml\System\Account
1214
{
1315
/**
1416
* Saving edited user information
1517
*
1618
* @return \Magento\Backend\Model\View\Result\Redirect
17-
* @throws LocalizedException
1819
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
1920
*/
2021
public function execute()
@@ -57,24 +58,19 @@ public function execute()
5758
$user->sendPasswordResetNotificationEmail();
5859
}
5960
$this->messageManager->addSuccess(__('The account has been saved.'));
60-
} catch (\Magento\Framework\Validator\Exception $e) {
61+
} catch (ValidatorException $e) {
6162
$this->messageManager->addMessages($e->getMessages());
6263
if ($e->getMessage()) {
6364
$this->messageManager->addError($e->getMessage());
6465
}
66+
} catch (LocalizedException $e) {
67+
$this->messageManager->addError($e->getMessage());
68+
} catch (\Exception $e) {
69+
$this->messageManager->addError(__('An error occurred while saving account.'));
6570
}
6671

67-
return $this->getDefaultResult();
68-
}
69-
70-
/**
71-
* {@inheritdoc}
72-
*
73-
* @return \Magento\Backend\Model\View\Result\Redirect
74-
*/
75-
public function getDefaultResult()
76-
{
77-
$resultRedirect = $this->resultRedirectFactory->create();
78-
return $resultRedirect->setPath('*/*');
72+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
73+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
74+
return $resultRedirect->setPath("*/*/");
7975
}
8076
}

0 commit comments

Comments
 (0)