1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\Tabulator; |
4
|
|
|
|
5
|
|
|
use LeKoala\ExcelImportExport\ExcelGridFieldExportButton; |
|
|
|
|
6
|
|
|
use SilverStripe\ORM\DataObject; |
7
|
|
|
use SilverStripe\ORM\RelationList; |
8
|
|
|
use SilverStripe\View\ArrayData; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* This component provides a button for exporting data |
12
|
|
|
* Depends on excel-import-export module |
13
|
|
|
*/ |
14
|
|
|
class TabulatorExportButton extends AbstractTabulatorTool |
15
|
|
|
{ |
16
|
|
|
public function __construct() |
17
|
|
|
{ |
18
|
|
|
parent::__construct(); |
19
|
|
|
$this->btn = new ExcelGridFieldExportButton(); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function forTemplate() |
23
|
|
|
{ |
24
|
|
|
$grid = $this->tabulatorGrid; |
25
|
|
|
$singleton = singleton($grid->getModelClass()); |
26
|
|
|
$context = []; |
27
|
|
|
if ($grid->getList() instanceof RelationList) { |
28
|
|
|
$record = $grid->getForm()->getRecord(); |
29
|
|
|
if ($record && $record instanceof DataObject) { |
|
|
|
|
30
|
|
|
$context['Parent'] = $record; |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
if (!$singleton->canCreate(null, $context)) { |
35
|
|
|
return false; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if (!$this->buttonName) { |
39
|
|
|
// provide a default button name, can be changed by calling {@link setButtonName()} on this component |
40
|
|
|
$this->buttonName = _t('Tabulator.ExportRecords', 'Export'); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$data = new ArrayData([ |
44
|
|
|
'ButtonName' => $this->buttonName, |
45
|
|
|
'ButtonClasses' => 'btn-secondary font-icon-export', |
46
|
|
|
'Icon' => $this->isAdmini() ? 'list_alt' : '', |
47
|
|
|
]); |
48
|
|
|
return $this->renderWith($this->getViewerTemplates(), $data); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getButton(): ExcelGridFieldExportButton |
52
|
|
|
{ |
53
|
|
|
return $this->btn; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function index() |
57
|
|
|
{ |
58
|
|
|
return $this->btn->handleExport($this->tabulatorGrid); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths