Skip to content

Commit 2fd6ef1

Browse files
author
Vasilii Burlacu
committed
magento/magento:20764 - Mass-action delete for Widgets
# Fixed codestyle and added improvements requested by maintainer
1 parent 0de0857 commit 2fd6ef1

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/MassDelete.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\Widget\Controller\Adminhtml\Widget\Instance;
810

911
use Magento\Backend\App\Action;
@@ -14,7 +16,7 @@
1416
use Magento\Framework\Controller\ResultFactory;
1517
use Magento\Framework\Controller\ResultInterface;
1618
use Magento\Framework\Exception\NoSuchEntityException;
17-
use Magento\Widget\Model\DeleteWidgetInstanceById;
19+
use Magento\Widget\Model\DeleteWidgetById;
1820

1921
/**
2022
* Class MassDelete
@@ -29,20 +31,20 @@ class MassDelete extends Action implements HttpPostActionInterface
2931
const ADMIN_RESOURCE = 'Magento_Widget::widget_instance';
3032

3133
/**
32-
* @var DeleteWidgetInstanceById
34+
* @var DeleteWidgetById
3335
*/
34-
private $deleteWidgetInstanceById;
36+
private $deleteWidgetById;
3537

3638
/**
3739
* @param Context $context
38-
* @param DeleteWidgetInstanceById $deleteWidgetInstanceById
40+
* @param DeleteWidgetById $deleteWidgetById
3941
*/
4042
public function __construct(
4143
Context $context,
42-
DeleteWidgetInstanceById $deleteWidgetInstanceById
44+
DeleteWidgetById $deleteWidgetById
4345
) {
4446
parent::__construct($context);
45-
$this->deleteWidgetInstanceById = $deleteWidgetInstanceById;
47+
$this->deleteWidgetById = $deleteWidgetById;
4648
}
4749

4850
/**
@@ -51,7 +53,7 @@ public function __construct(
5153
* @return Redirect
5254
* @throws \Exception
5355
*/
54-
public function execute()
56+
public function execute(): Redirect
5557
{
5658
$deletedInstances = 0;
5759
$notDeletedInstances = [];
@@ -69,7 +71,7 @@ public function execute()
6971

7072
foreach ($instanceIds as $instanceId) {
7173
try {
72-
$this->deleteWidgetInstanceById->execute((int) $instanceId);
74+
$this->deleteWidgetById->execute((int) $instanceId);
7375
$deletedInstances++;
7476
} catch (NoSuchEntityException $e) {
7577
$notDeletedInstances[] = $instanceId;
@@ -96,7 +98,7 @@ public function execute()
9698
/**
9799
* @return array
98100
*/
99-
private function getInstanceIds()
101+
private function getInstanceIds(): array
100102
{
101103
$instanceIds = $this->getRequest()->getParam('delete');
102104

@@ -110,7 +112,7 @@ private function getInstanceIds()
110112
/**
111113
* @return ResultInterface|RedirectInterface
112114
*/
113-
private function getResultPage()
115+
private function getResultPage(): ?ResultInterface
114116
{
115117
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
116118
}

app/code/Magento/Widget/Model/DeleteWidgetInstanceById.php renamed to app/code/Magento/Widget/Model/DeleteWidgetById.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Widget\Model;
89

@@ -12,9 +13,9 @@
1213
use Magento\Widget\Model\Widget\Instance as WidgetInstance;
1314

1415
/**
15-
* Class DeleteWidgetInstanceById
16+
* Class DeleteWidgetById
1617
*/
17-
class DeleteWidgetInstanceById
18+
class DeleteWidgetById
1819
{
1920
/**
2021
* @var InstanceResourceModel
@@ -57,7 +58,7 @@ public function execute(int $instanceId)
5758
* @return WidgetInstance
5859
* @throws NoSuchEntityException
5960
*/
60-
private function getWidgetById(int $instanceId)
61+
private function getWidgetById(int $instanceId): WidgetInstance
6162
{
6263
/** @var WidgetInstance $widgetInstance */
6364
$widgetInstance = $this->instanceFactory->create();

app/code/Magento/Widget/etc/di.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,4 @@
3434
<plugin name="widget-layout-update-plugin"
3535
type="Magento\Widget\Model\ResourceModel\Layout\Plugin" sortOrder="10"/>
3636
</type>
37-
<preference for="Magento\Widget\Api\DeleteWidgetInstanceByIdInterface"
38-
type="Magento\Widget\Model\DeleteWidgetInstanceById" />
3937
</config>

0 commit comments

Comments
 (0)