Skip to content

Commit 0ccf08c

Browse files
author
vpaladiychuk
committed
Merge remote-tracking branch 'origin/MAGETWO-26762' into MAGETWO-26762
2 parents e00eb35 + c767702 commit 0ccf08c

File tree

28 files changed

+647
-646
lines changed

28 files changed

+647
-646
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,24 @@ class CleanImages extends \Magento\Backend\Controller\Adminhtml\Cache
1414
* Clean JS/css files cache
1515
*
1616
* @return \Magento\Backend\Model\View\Result\Redirect
17+
* @throws LocalizedException
1718
*/
1819
public function execute()
1920
{
20-
try {
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.'));
24-
} catch (LocalizedException $e) {
25-
$this->messageManager->addError($e->getMessage());
26-
} catch (\Exception $e) {
27-
$this->messageManager->addException($e, __('An error occurred while clearing the image cache.'));
28-
}
29-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
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.'));
24+
25+
return $this->getDefaultRedirect();
26+
}
27+
28+
/**
29+
* {@inheritdoc}
30+
*
31+
* @return \Magento\Backend\Model\View\Result\Redirect
32+
*/
33+
public function getDefaultRedirect()
34+
{
3035
$resultRedirect = $this->resultRedirectFactory->create();
3136
return $resultRedirect->setPath('adminhtml/*');
3237
}

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,24 @@ class CleanMedia extends \Magento\Backend\Controller\Adminhtml\Cache
1414
* Clean JS/css files cache
1515
*
1616
* @return \Magento\Backend\Model\View\Result\Redirect
17+
* @throws LocalizedException
1718
*/
1819
public function execute()
1920
{
20-
try {
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.'));
24-
} catch (LocalizedException $e) {
25-
$this->messageManager->addError($e->getMessage());
26-
} catch (\Exception $e) {
27-
$this->messageManager->addException($e, __('An error occurred while clearing the JavaScript/CSS cache.'));
28-
}
29-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
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.'));
24+
25+
return $this->getDefaultRedirect();
26+
}
27+
28+
/**
29+
* {@inheritdoc}
30+
*
31+
* @return \Magento\Backend\Model\View\Result\Redirect
32+
*/
33+
public function getDefaultRedirect()
34+
{
3035
$resultRedirect = $this->resultRedirectFactory->create();
3136
return $resultRedirect->setPath('adminhtml/*');
3237
}

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,38 @@ class MassDisable extends \Magento\Backend\Controller\Adminhtml\Cache
1414
* Mass action for cache disabling
1515
*
1616
* @return \Magento\Backend\Model\View\Result\Redirect
17+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
1718
*/
1819
public function execute()
1920
{
20-
try {
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++;
31-
}
32-
$this->_cacheTypeList->cleanType($code);
33-
}
34-
if ($updatedTypes > 0) {
35-
$this->_cacheState->persist();
36-
$this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes));
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++;
3731
}
38-
} catch (LocalizedException $e) {
39-
$this->messageManager->addError($e->getMessage());
40-
} catch (\Exception $e) {
41-
$this->messageManager->addException($e, __('An error occurred while disabling cache.'));
32+
$this->_cacheTypeList->cleanType($code);
4233
}
43-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
34+
if ($updatedTypes > 0) {
35+
$this->_cacheState->persist();
36+
$this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes));
37+
}
38+
39+
return $this->getDefaultRedirect();
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*
45+
* @return \Magento\Backend\Model\View\Result\Redirect
46+
*/
47+
public function getDefaultRedirect()
48+
{
4449
$resultRedirect = $this->resultRedirectFactory->create();
4550
return $resultRedirect->setPath('adminhtml/*');
4651
}

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

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,37 @@ class MassEnable extends \Magento\Backend\Controller\Adminhtml\Cache
1414
* Mass action for cache enabling
1515
*
1616
* @return \Magento\Backend\Model\View\Result\Redirect
17+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
1718
*/
1819
public function execute()
1920
{
20-
try {
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++;
31-
}
32-
}
33-
if ($updatedTypes > 0) {
34-
$this->_cacheState->persist();
35-
$this->messageManager->addSuccess(__("%1 cache type(s) enabled.", $updatedTypes));
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++;
3631
}
37-
} catch (LocalizedException $e) {
38-
$this->messageManager->addError($e->getMessage());
39-
} catch (\Exception $e) {
40-
$this->messageManager->addException($e, __('An error occurred while enabling cache.'));
4132
}
42-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
33+
if ($updatedTypes > 0) {
34+
$this->_cacheState->persist();
35+
$this->messageManager->addSuccess(__("%1 cache type(s) enabled.", $updatedTypes));
36+
}
37+
38+
return $this->getDefaultRedirect();
39+
}
40+
41+
/**
42+
* {@inheritdoc}
43+
*
44+
* @return \Magento\Backend\Model\View\Result\Redirect
45+
*/
46+
public function getDefaultRedirect()
47+
{
4348
$resultRedirect = $this->resultRedirectFactory->create();
4449
return $resultRedirect->setPath('adminhtml/*');
4550
}

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

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,35 @@ class MassRefresh extends \Magento\Backend\Controller\Adminhtml\Cache
1414
* Mass action for cache refresh
1515
*
1616
* @return \Magento\Backend\Model\View\Result\Redirect
17+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
1718
*/
1819
public function execute()
1920
{
20-
try {
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 $type) {
28-
$this->_cacheTypeList->cleanType($type);
29-
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => $type]);
30-
$updatedTypes++;
31-
}
32-
if ($updatedTypes > 0) {
33-
$this->messageManager->addSuccess(__("%1 cache type(s) refreshed.", $updatedTypes));
34-
}
35-
} catch (LocalizedException $e) {
36-
$this->messageManager->addError($e->getMessage());
37-
} catch (\Exception $e) {
38-
$this->messageManager->addException($e, __('An error occurred while refreshing cache.'));
21+
$types = $this->getRequest()->getParam('types');
22+
$updatedTypes = 0;
23+
if (!is_array($types)) {
24+
$types = [];
3925
}
40-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
26+
$this->_validateTypes($types);
27+
foreach ($types as $type) {
28+
$this->_cacheTypeList->cleanType($type);
29+
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => $type]);
30+
$updatedTypes++;
31+
}
32+
if ($updatedTypes > 0) {
33+
$this->messageManager->addSuccess(__("%1 cache type(s) refreshed.", $updatedTypes));
34+
}
35+
36+
return $this->getDefaultRedirect();
37+
}
38+
39+
/**
40+
* {@inheritdoc}
41+
*
42+
* @return \Magento\Backend\Model\View\Result\Redirect
43+
*/
44+
public function getDefaultRedirect()
45+
{
4146
$resultRedirect = $this->resultRedirectFactory->create();
4247
return $resultRedirect->setPath('adminhtml/*');
4348
}

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

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

2727
/**
2828
* @return \Magento\Backend\Model\View\Result\Redirect
29+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
2930
*/
3031
public function execute()
3132
{
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);
33+
$collectionsNames = array_values($this->reportTypes);
34+
foreach ($collectionsNames as $collectionName) {
35+
$this->_objectManager->create($collectionName)->aggregate();
4136
}
42-
return $this->resultRedirectFactory->create()->setPath('*/*');
37+
$this->messageManager->addSuccess(__('We updated lifetime statistic.'));
38+
39+
return $this->getDefaultRedirect();
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*
45+
* @return \Magento\Backend\Model\View\Result\Redirect
46+
*/
47+
public function getDefaultRedirect()
48+
{
49+
$resultRedirect = $this->resultRedirectFactory->create();
50+
return $resultRedirect->setPath('*/*');
4351
}
4452
}

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
namespace Magento\Backend\Controller\Adminhtml\System\Account;
77

88
use Magento\Framework\Exception\AuthenticationException;
9+
use Magento\Framework\Exception\LocalizedException;
910

1011
class Save extends \Magento\Backend\Controller\Adminhtml\System\Account
1112
{
1213
/**
1314
* Saving edited user information
1415
*
1516
* @return \Magento\Backend\Model\View\Result\Redirect
17+
* @throws LocalizedException
1618
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
1719
*/
1820
public function execute()
@@ -25,17 +27,11 @@ public function execute()
2527
/** @var $user \Magento\User\Model\User */
2628
$user = $this->_objectManager->create('Magento\User\Model\User')->load($userId);
2729

28-
$user->setId(
29-
$userId
30-
)->setUsername(
31-
$this->getRequest()->getParam('username', false)
32-
)->setFirstname(
33-
$this->getRequest()->getParam('firstname', false)
34-
)->setLastname(
35-
$this->getRequest()->getParam('lastname', false)
36-
)->setEmail(
37-
strtolower($this->getRequest()->getParam('email', false))
38-
);
30+
$user->setId($userId)
31+
->setUsername($this->getRequest()->getParam('username', false))
32+
->setFirstname($this->getRequest()->getParam('firstname', false))
33+
->setLastname($this->getRequest()->getParam('lastname', false))
34+
->setEmail(strtolower($this->getRequest()->getParam('email', false)));
3935

4036
if ($this->_objectManager->get('Magento\Framework\Locale\Validator')->isValid($interfaceLocale)) {
4137
$user->setInterfaceLocale($interfaceLocale);
@@ -66,13 +62,19 @@ public function execute()
6662
if ($e->getMessage()) {
6763
$this->messageManager->addError($e->getMessage());
6864
}
69-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
70-
$this->messageManager->addError($e->getMessage());
71-
} catch (\Exception $e) {
72-
$this->messageManager->addError(__('An error occurred while saving account.'));
7365
}
74-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
66+
67+
return $this->getDefaultRedirect();
68+
}
69+
70+
/**
71+
* {@inheritdoc}
72+
*
73+
* @return \Magento\Backend\Model\View\Result\Redirect
74+
*/
75+
public function getDefaultRedirect()
76+
{
7577
$resultRedirect = $this->resultRedirectFactory->create();
76-
return $resultRedirect->setPath("*/*/");
78+
return $resultRedirect->setPath('*/*');
7779
}
7880
}

app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroupPost.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class DeleteGroupPost extends \Magento\Backend\Controller\Adminhtml\System\Store
1010
{
1111
/**
1212
* @return \Magento\Backend\Model\View\Result\Redirect
13+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
1314
*/
1415
public function execute()
1516
{
@@ -31,15 +32,8 @@ public function execute()
3132
return $redirectResult->setPath('*/*/editGroup', ['group_id' => $itemId]);
3233
}
3334

34-
try {
35-
$model->delete();
36-
$this->messageManager->addSuccess(__('The store has been deleted.'));
37-
return $redirectResult->setPath('adminhtml/*/');
38-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
39-
$this->messageManager->addError($e->getMessage());
40-
} catch (\Exception $e) {
41-
$this->messageManager->addException($e, __('Unable to delete store. Please, try again later.'));
42-
}
43-
return $redirectResult->setPath('adminhtml/*/editGroup', ['group_id' => $itemId]);
35+
$model->delete();
36+
$this->messageManager->addSuccess(__('The store has been deleted.'));
37+
return $redirectResult->setPath('adminhtml/*/');
4438
}
4539
}

0 commit comments

Comments
 (0)