Skip to content

Commit 52eb11a

Browse files
committed
Move mass actions from subclasses to XML layout
1 parent 4cc923b commit 52eb11a

3 files changed

Lines changed: 42 additions & 13 deletions

File tree

Grid/MassAction/AbstractMassAction.php

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Loki\AdminComponents\Grid\MassAction;
4+
5+
class EnableMassAction extends MassAction
6+
{
7+
protected function getUrlParameters(): array
8+
{
9+
return ['status' => 1];
10+
}
11+
}

Grid/MassAction/MassAction.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Loki\AdminComponents\Grid\MassAction;
4+
5+
use Magento\Framework\UrlFactory;
6+
7+
class MassAction implements MassActionInterface
8+
{
9+
public function __construct(
10+
protected UrlFactory $urlFactory,
11+
protected string $label,
12+
protected string $url,
13+
protected array $urlParameters = [],
14+
) {
15+
}
16+
17+
public function getLabel(): string
18+
{
19+
return $this->label;
20+
}
21+
22+
public function getUrl(): string
23+
{
24+
return $this->urlFactory->create()->getUrl($this->url, $this->getUrlParameters());
25+
}
26+
27+
protected function getUrlParameters(): array
28+
{
29+
return $this->getUrlParameters();
30+
}
31+
}

0 commit comments

Comments
 (0)