BulkUnlinkAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getI18nLabel() 0 3 1
A process() 0 8 2
1
<?php
2
3
namespace LeKoala\Tabulator\BulkActions;
4
5
use SilverStripe\Control\HTTPRequest;
6
use LeKoala\Tabulator\AbstractBulkAction;
7
8
/**
9
 * Bulk action handler for unlinking records.
10
 */
11
class BulkUnlinkAction extends AbstractBulkAction
12
{
13
    protected string $name = 'unlink';
14
    protected string $label = 'Unlink';
15
    protected bool $xhr = true;
16
17
    public function getI18nLabel(): string
18
    {
19
        return _t(__CLASS__ . '.UNLINK_SELECT_LABEL', $this->getLabel());
20
    }
21
22
    public function process(HTTPRequest $request): string
23
    {
24
        $ids = $this->getRecordIDList();
25
        if (!empty($ids)) {
26
            $this->tabulatorGrid->getDataList()->removeMany($ids);
27
        }
28
        $result = _t(__CLASS__ . ".RECORDSUNLINKED", "{count} records unlinked", ["count" => count($ids)]);
29
        return $result;
30
    }
31
}
32